console.log(serviceList)
打印serviceList时报错
data: {
serviceList: []
},
getNearServices: function () {
let that = this;
const { latitude, longitude } = this.data;
console.log(this.data)
wx.cloud.callFunction({
name: 'getService',
data: {
latitude,
longitude
},
success: function (res) {
console.log('getNearServices-->',res);
that.setData({
serviceList: res.result.list
})
console.log(serviceList)
},
fail: console.error
})
},
console.log(that.serviceList)打印出来的是undefined
console.log(res.result.list)这个打印结果是对对。
为什么啊。