使用this.data还是this.setData对themes赋值,test里获取不到想要的值
Page({
data: {
themeA:null,
bannerB:null,
grid:[],
activityD:null,
themes:[]
},
onLoad:async function (options) {
this.initAllData();
this.test();
},
async initAllData(){
// const themeA = await Theme.getHomeLocationA();
const themes = await Theme.getThemes();
// this.data.themes = themes;
// console.log(this.data.themes)
const themeA = themes.find(v=>v.name === 't-1')
const themeE = themes.find(v=>v.name === 't-2')
const bannerB = await Banner.getHomeLocationB();
const grid = await Category.getHomeLocationC();
const activityD = await Activity.getHomeLocationD();
this.setData({
themeA,
bannerB,
grid,
activityD,
themes
})
},
test(){
console.log(this.data)
console.log(this.data.themes)
}
33
收起
正在回答 回答被采纳积分+1
2回答

恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星