_getCategoryDetail(currentIndex) { const shoesID = this.data.categories[currentIndex].shoesID const details = this.data.categories[currentIndex] const categoryData = this.data.categoryData; for (let i = 0; i < shoesID.length; i++) { categoryData[currentIndex][i] = { title: "" , image: "" } getShoesDetail(shoesID[i]).then(res => { categoryData[currentIndex][i].title = String(res.data[0]._shoesID) categoryData[currentIndex][i].image = String(res.data[0]._hostgraph) }) } this.setData({ categoryData
console.log(categoryData[currentIndex])
|
|
把上方category.js中categoryData[currentIndex]传给下方w-content.js中的categoryDetail
categoryDetail: { type: Array, observer: function (newVal, oldVal) { console. log (newVal) } } }, |
getShoesDetail为调用的查询数据库函数,外面的this.setData不渲染图层,以下是两边打印的结果
上方是w-content.js:9 下方是category.js:67