当前位置:网站首页>Get wechat avatar and nickname with uniapp

Get wechat avatar and nickname with uniapp

2022-07-05 19:06:00 gblfy

<view class="userInformation">
	 <!--  User defined Avatar  -->
	 <view class="userPortrait">
		  <image :src="yonghuwx.avatarUrl" mode="widthFix"></image>
	 </view>
	 <view class="userLook" >
		  <!--  User defined name  -->
		  <view class="user-title clamp">{
    {
    yonghuwx.nickName}}</view>
		  <view class="user-edit"> Check your profile </view>
	 </view>
</view>

onLoad(){
    
    let that = this;
		uni.login({
    
			provider:'weixin',
			success:function(loginRes) {
    
			//  Get user information 
			    uni.getUserInfo({
    
				    provider:'weixin',
					success:function(infoRes){
    
				   	    that.userInfo= infoRes.userInfo
				    	console.log(that.userInfo)
					}
				});
			}
		});
}

原网站

版权声明
本文为[gblfy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207051839081750.html