開放能力?/用戶信息?/獲取頭像昵稱
頭像昵稱填寫
從基礎(chǔ)庫(kù)?2.21.2?開始支持
當(dāng)小程序需要讓用戶完善個(gè)人資料時(shí),可以通過微信提供的頭像昵稱填寫能力快速完善。
使用方法
頭像選擇
需要將?button?組件?open-type
?的值設(shè)置為?chooseAvatar
,當(dāng)用戶選擇需要使用的頭像之后,可以通過?bindchooseavatar
?事件回調(diào)獲取到獲取到頭像信息的臨時(shí)路徑。
代碼示例
在開發(fā)者工具中預(yù)覽效果
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image class="avatar" src="{{avatarUrl}}"></image>
</button>
<input type="nickname" class="weui-input" placeholder="請(qǐng)輸入昵稱"/>
把上面的修改為
?文章來源:http://www.zghlxwxcb.cn/news/detail-627177.html
<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
<image class="avatar" :src="avatarUrl"></image>
</button>
<input type="nickname" class="weui-input" placeholder="請(qǐng)輸入昵稱" />
data() {
return {
avatarUrl: 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0',
}
},
methods: {
onChooseAvatar(e) {
this.avatarUrl = e.detail.avatarUrl
},
}
頭像在微信開發(fā)工具有效果,昵稱在真機(jī)才有效果。文章來源地址http://www.zghlxwxcb.cn/news/detail-627177.html
到了這里,關(guān)于uniapp onChooseAvatar,uniapp微信頭像昵稱填寫,uniapp chooseAvatar,does not have a method “onChooseAvatar“的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!