描述
解决方法
改成用getUserProfile
例子
使用bindgetuserinfo
user.wxml:
<button bindgetuserinfo="useral" open-type="getUserInfo" class="button1">用户点击获取信息</button>
user.js
useral(e){
console.log(e);
},
输出:

变成"微信用户"了…
改成getUserProfile
user.wxml
<button
type="primary"
class="botton2"
bindtap="useral2"
>
点击获取用户信息
</button>
user.wxss
useral2(){
wx.getUserProfile({
desc:'获取您的用户头像等信息',
success:res=>{
console.log("用户res:",res);
},
fail:res=>{
console.log("用户拒绝授权...");
}
});
},
结果
授权询问

不同意授权

同意授权


本文介绍了在微信小程序API更新后,由于getuserinfo无法获取用户信息的问题,提出解决方案——改用getUserProfile。详细说明了如何在user.wxml和user.js中进行修改,并展示了不同授权状态下的用户反馈。

471

被折叠的 条评论
为什么被折叠?



