getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
直接调用getUserProfile方法 wx.getUserProfile 无返回数据,无响应。。
使用button触发getUserProfile方法,wx.getUserProfile有数据返回。why?????????
<button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
*开发工具已更新,确认支持wx.getUserProfile接口。
网友回复
|G.XIAO|:
getUserProfile 必须是用户点击才能触发
另外可以看看用户授权的前世今生https://developers.weixin.qq.com/community/develop/article/doc/000c8ce9a10070794cfbb0c085b013