关于微信小程序:微信小程序获取用户头像信息以及修改用户头像

0次阅读

共计 358 个字符,预计需要花费 1 分钟才能阅读完成。

这里次要用到 button 的 open-type 性能,官网已有阐明:

button 设置 open-type="chooseAvatar",来使bindchooseavatar 办法失效,在 bindchooseavatar 指定的函数中获取用户的头像信息

<button open-type="chooseAvatar"  bindchooseavatar="chooseavatar"></button>

 chooseavatar(e){
    this.setData({avatar: e.detail.avatarUrl})
},

该办法触发后会自动弹出提示框,让用户抉择头像,用户抉择的头像会在 bindchooseavatar 指定的函数内获取,e.detail.avatarUrl就是以后的头像信息。
调用批改用户信息接口,传入该门路信息即可。

正文完
 0