微信展示用户头像、昵称、城市、性别的方法
作者:
云之一 | 来源:发表于
2021-05-25 13:30 被阅读0次1、直接使用open-data
组件
<open-data type="groupName" open-gid="xxxxxx"></open-data>
<open-data type="userAvatarUrl"></open-data>
<open-data type="userGender" lang="zh_CN"></open-data>
2、wx.getUserProfile
- 每次调用此接口均会弹窗让用户授权,因此要注意保存用户信息
- 页面产生点击事件(例如 button 上 bindtap 的回调中)后才可调用
//.wxml
<button bindtap="getUserProfile"> 获取头像昵称 </button>
//.js
getUserProfile(e) {
wx.getUserProfile({
desc: '展示用户信息', /
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
本文标题:微信展示用户头像、昵称、城市、性别的方法
本文链接:https://www.haomeiwen.com/subject/visadltx.html
网友评论