uni-app 新版微信用户获取userInfo方法 uni.getUserProfile
微信更新了新的获取用户信息的方法,之前的getUserInfo
方法获取不到用户的头像等信息,继续使用也会得到 灰色的头像 不是真正的用户头像
之前的获uniapp 中获取用户信息方法:
<button open-type="getUserInfo" @getuserinfo="getUserInfo">立即登录</button>
新的 获取用户信息方法:
//不要使用 open-type 就简单的一个@click 事件
//方法:
<button @click="getUserInfo">请登录</button>
对应的 js:
getUserInfo(){
console.log("aaaa")
uni.getUserProfile({
desc:'Wexin', // 这个参数是必须的
success:res=>{
console.log("用户信息",res.rawData)
}
})
}