//js代码
Page({
data: {
word_list: []
},
})
console.log('开始');
let aa = wx.cloud.callFunction({
name:'get_week_words',
}).then(res=>{
// this.setData({
// word_list: this.data.word_list.push(JSON.parse(res.result).data)
// })
console.log(JSON.stringify(res));
console.log(JSON.stringify(res.result.data[0].chs));
}).catch(err=>{
console.log(err);
})
console.log('结束');
//云函数代码
exports.main = async (event, context) => {
var res = await cloud.database().collection("word")
.get();
return res;
}
//log打印
不需要用JSON.parse
this.setData({
word_list: res.result.data
})
word_list: res.result.data
})
console.log(word_list[0].chs);
不行,报错word_list没有定义