小程序上线后获取用户信息偶尔报错getUserInfor
- 当前 Bug 的表现(可附上截图)
- 提供一个最简复现 Demo
getUserInfo: function (e) {
var that = this
console.log(e)
if (e.detail.errMsg == ‘getUserInfo:ok’) {
wx.showLoading({
title: ‘获取中…’,
})
that.setData({
hasUserInfo: true,
})
getApp().globalData.userface = e.detail.userInfo.avatarUrl
app.globalData.userInfo = e.detail.userInfo
complete(that,e.detail).then(app.getAuthKey().then(function (arr1) {
that.onReady()
}))
}
},
complete()方法是补充用户信息相当于app.getUser()方法,app.getAuthKey()是重新登录。