小程序
小游戏
企业微信
微信支付
扫描小程序码分享
wx.login({
success(res) {
//发起网络请求
wx.cloud.callFunction({
name: 'login'
}).then(res => console.log(res)).then(db.collection('zhongdui').add({
data: {
openid: res.result
}
})).then(
kkid = res.result,
)
})
其中kkid为全局变量,函数运行后kkid的值为undefined
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
}).then(res2 => {
console.log(res2)
kkid = res.result
return db.collection('zhongdui').add({
如果要在wx.login之外能打印kkid 值,还需配合async / await 使用
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
楼上好厉害,
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
wx.login({
success(res) {
//发起网络请求
wx.cloud.callFunction({
name: 'login'
}).then(res2 => {
console.log(res2)
kkid = res.result
return db.collection('zhongdui').add({
data: {
openid: res.result
}
})
})
}
})
如果要在wx.login之外能打印kkid 值,还需配合async / await 使用
你那么写,第二个和第三个then里res是不存在的
楼上好厉害,