如何在js中通过多个函数多次改变data中的值?
在js里通过一个function中获取当前用户的openid,然后存到page里的data中,在其他fuction里再调用data的值返回就是空,请问什么原因? Page({
data: {
useropenid: '',
my_order_list: []
},
getopenid_local() {
var that = this
wx.cloud.callFunction({
name: "getopenid",
}).then(res => {
that.setData({
useropenid: res.result.openid
})
console.log("data.useropenid: ", that.data.useropenid)
}).catch(res => {
console.log("openid获取失败", res)
})
get_order_list() {
var that = this
that.getopenid_local()
console.log("orderlist里的openid:", that.data.useropenid)
wx.cloud.callFunction({
name: "get_invite_list",
data: {
cloud_openid: that.data.useropenid
},
success(res) {
that.setData({
my_order_list: res.data
})
console.log("成功获取res的数据:", res, that.data.my_order_list)
}, fail(res) {
console.log("获取res的数据失败", res)
}
})
},
[图片]