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

这里次要用到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就是以后的头像信息。
调用批改用户信息接口,传入该门路信息即可。

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理