获取头像
xml
<button class="avatar-wrapper" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">
<image class="avatar" src="{{userInfo.avatar || ''}}"></image>
</button>
js
// 选择头像
onChooseAvatar(e) {
console.log('选择头像', e);
const {
avatarUrl
} = e.detail
this.setData({
['userInfo.avatar']: avatarUrl
})
},
获取昵称
xml
<input type="nickname" class="name-input" name="nickname" value="{{userInfo.nickName||''}}" bindchange="onInput" placeholder="请输入昵称" />
js
// 输入昵称
onInput(e) {
const {
value
} = e.detail
console.log('输入昵称', value);
this.setData({
['userInfo.nickName']: value
})
},