uni-app在微信小程序中无法拉起用户授权面板,uni.getUserInfo直接返回匿名数据

问题描述:在开发中通过微信小程序文档(https://developers.weixin.qq.com/miniprogram/dev/component/button.html)和uni-app文档(https://uniapp.dcloud.io/api/plugins/login?id=getuserinfo)配置button属性与绑定事件实现拉起授权获取用户信息面板:open-type、@getuserinfo="bindGetUserInfo"、withCredentials,在莫名的一波操作后,无论如何点击按钮都无法弹出授权面板,并且在按钮绑定的getuserinfo事件中,直接返回匿名数据

view代码

script代码

 点击按钮返回的数据

uni-app在微信小程序中无法拉起用户授权面板,uni.getUserInfo直接返回匿名数据_第1张图片

解决:搜了一波网上的文档,还是一样的结果,最后到微信开发社区进行搜索,才发现这个官方公告(https://developers.weixin.qq.com/community/develop/doc/000cacfa20ce88df04cb468bc52801?highLine=getUserProfile),原来官网调整了小程序登录、用户信息相关接口,通过绑定点击事件与调用uni.getUserProfile方法即可,代码如下:

view代码 

script代码

成功拉起弹窗

uni-app在微信小程序中无法拉起用户授权面板,uni.getUserInfo直接返回匿名数据_第2张图片

你可能感兴趣的:(前端,小程序,小程序)