小程序wx.getUserProfile(巨坑)

官方:2021年4月13日后发布的小程序新版本,无法通过wx.getUserInfo与获取用户个人信息

image.png

我是使用的是 基础库 2.14.1 并不能使用,报错找不到方法
改用最新的 2.16.0才能使用(官方并没有说明)

如果不能使用
出现以下情况

console.log('canIUse', wx.canIUse('wx.getUserProfile'))  //canIUse false
在这里插入图片描述

把调试基础库调到最高版本,并升级微信开发者工具到最新版本

好了现在代码就跑起来了


可以在模拟器唤起授权 获得用户信息
getUserProfile() {
            uni.getUserProfile({
                desc: "登录",
                success: (res) => {
                    debugger;
                    console.log(res);
                },
                fail: (res) => {
                    debugger;
                    console.log(res);
        },
    });
},

你可能感兴趣的:(小程序wx.getUserProfile(巨坑))