App({
Data:{
openid:''
},
onLaunch: function () {
wx.cloud.callFunction({
name: 'login',
success: res => {
console.log('[云函数] [login] user openid: ', res.result.openid)
openid = res.result.openid
},
fail: err => {
console.error('[云函数] [login] 调用失败', err)
}
})
},
})
用这个
this.globalData.openid = res.result.openid
this.Data.openid = res.result.openid
console.log(this.Data.openid)
这里打印不出来吗?如果打印出来了,不就已经取值成功了?