关注公告很重要!!!
最新使用:(我用的时uni-app)
template
<view class="user-info" @tap="shouquan">
</view>
js
methods:{
shouquan() {
uni.getUserProfile({
desc: '登录',
success: (res) => {
uni.setStorageSync("userInfo", res.userInfo)
uni.navigateTo({
url: "../login/login"
})
},
fail: (res) => {
console.log(res)
}
});
},
}
1、要写desc:要不然回报错误:getUserProfile:fail parameter error: parameter.desc should be String instead of Undefined;
2、uni.getUserProfil和uni.login不能一起使用,否则会报错:getUserProfile:fail can only be invoked by user TAP gesture