小程序wx.getUserProfile怎么使用
官方:2021年4月13日后发布的小程序新版本,无法通过wx.getUserInfo与获取用户个人信息
现在我们开始使用wx.getUserProfile来更换之前的wx.getUserInfo接口或
直接上代码
wxml:
<button class="wxlogbtn" catchtap="newGetInfo">登录</button>
js:
newGetInfo: function (e) {
wx.getUserProfile({
desc: '正在获取', //不写不弹提示框
success: function (res) {
console.log("获取成功:", res)
},
fail: function (err) {
console.log("获取失败: ", err)
}
})
}

如果不能使用
出现以下情况
console.log('canIUse', wx.canIUse('wx.getUserProfile')) //canIUse false

把调试基础库调到最高版本,并升级微信开发者工具到最新版本
好了现在代码就跑起来了
更多有用知识、资源,请关注我们,记得关注一键三连!

扫码回复 “前端” 获取私密资源
3061

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



