小程序
小游戏
企业微信
微信支付
扫描小程序码分享
我在app.js通过wx.login方法获取到code之后,调用后台的方法转换成sessionKey,然后缓存起来,在其他页面还没从缓存中获取到数据就先调用了接口
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
增加一个callback,具体函数内容在其他页面初始化:
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
onLoad: function () {
wx.request({
url: app.globalData.domain,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
data: {
sessionKey: wx.getStorageSync('sessionKey'),
success: function (result) {
console.log(result);
})
怎么改?比如这样...
用一个事件回调
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
增加一个callback,具体函数内容在其他页面初始化:
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
onLoad: function () {
wx.request({
url: app.globalData.domain,
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
data: {
sessionKey: wx.getStorageSync('sessionKey'),
},
success: function (result) {
console.log(result);
}
})
}
怎么改?比如这样...
用一个事件回调