微信小程序-获取用户头像信息以及修改用户头像
兔子先森兔子先森 -这里主要用到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
就是当前的头像信息。
调用修改用户信息接口,传入该路径信息即可。
特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。