Component({ data: { newNews: [] }, lifetimes: { ready: function() { wx.showLoading({ title: "加载中" }) const db = wx.cloud.database() db.collection("likeData").where({ type: "message" }).get({ success: function (res) { if (res.data.length == 0) { wx.hideLoading() return } this.processData(res.data) }.bind(this) }) } }, methods: { processData: function (arr) { const db = wx.cloud.database() for (let i = 0; i < arr.length; i++) { db.collection("mainData").doc(arr[i].id).get({ success: function (res) { arr[i].publisherAvatar = res.data.publisherAvatar arr[i].publisherName = res.data.publisherName arr[i].title = res.data.title arr[i].subTitle = res.data.subTitle this.setData({ newNews: arr }) wx.hideLoading() }.bind(this) }) } } } })