首先 在uniapp里

<!-- #ifdef MP-WEIXIN -->
<image :src="imgs" mode=""></image>
<text>{{title}}</text>
<button type="default" @click="huoqu">获取头像名称</button>
<!-- #endif -->

获取名称 写点击click事件

 

在js里写

export default {
data() {
return {
imgs:'',
title:''
}
},
onShow() {
let a=uni.getStorageSync('users')
console.log(a)

if(a){
this.imgs=a.avatarUrl
this.title=a.nickName
}
},
methods: {
huoqu(){
uni.getUserProfile({
desc:'登录',
success:(res)=>{
console.log(res);
this.imgs=res.userInfo.avatarUrl
this.title=res.userInfo.nickName
uni.setStorageSync('users',res.userInfo)
},
fail:(err)=>{
console.log(err);
}
})

}
}
}

运行小程序之后  

在nuiapp里获取头像名称_#endif

 

 就能获取了

然后根据上面的代码 点允许 就能获取头像跟名称了