uniapp實現小程序獲取用戶信息


根據小程序官方文檔我們可以知道獲取用戶信息api
  根據open-type='getUserInfo'來實現

<template>
  <button open-type="getUserInfo" @getuserinfo='getUserInfo'>{{nickname ? nickname : '點擊登錄'}}</button>

</template>
export default {
  data(){
    return:{
      nickname: '',
      avatar: '',
    }
  },
  methods:{
    getUserInfo(res){
      console.log(res)//這里是獲取的用戶信息的相關數據
      this.nickname = res.detail.userInfo.nickname,
      this.avatar = res.detail.userInfo.avatarUrl
    }
  }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM