其他分享
首页 > 其他分享> > uniapp uni.getUserProfile的使用

uniapp uni.getUserProfile的使用

作者:互联网

为优化开发者调整接口的体验,回收wx.getUserInfo接口可获取用户授权的个人信息能力的截止时间由2021年4月13日调整至2021年4月28日24时;

所以最近用uni.getUserInfo()一直获取不到数据,

一、使用方法

 html中:

<button @click="get_wx_user" class="bottom-btn" type="default" size="mini">登入</button>

  js中

        get_wx_user() {
                     
// 查看是否授权
                    wx.getSetting({
                        success (res){
                            if (res.authSetting['scope.userInfo']) {
                                uni.getUserProfile({
                                    desc: '獲取您的昵稱、頭像、地區及性別',
                                    success: res1 => {
                                        console.log("aa",res1);
                                    },
                                    fail: err => {
                                        console.log(JSON.stringify(err));
                                    }
                                });    
                            }
                        }
                    })
                     
              },

 

标签:uniapp,console,err,res,uni,getUserProfile,wx
来源: https://www.cnblogs.com/zhangyouwu/p/16207257.html