getUserProfile 调用失败
发布于 4 年前 作者 junxu 1138 次浏览 来自 问答

https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserProfile.html

期望行为:

当用户授权,调用 success 回调成功

目前行为:

不弹出授权框,{errMsg: “getUserProfile:fail can only be invoked by user TAP gesture.”}

Note:

如果此方法必须要绑定某个事件使用,请在文档中明确注明「此方法必须在 X 事件的响应函数中使用,否则报错」。请不要浪费开发者的时间

1 回复

需要用户手动点击触发。

<button bindtap="handleClick">点我授权<button>

不能直接在onLoad里调用

handleClick() {
   wx.getUserProfie({
     success: res => {
       console.log(res.userInfo)
     }
   })
 }
回到顶部