1,昵稱:使用到的是微信小程序文檔里的api
input框的type值設(shè)置為nickname,再使用雙向綁定的方法拿到值
<input type="nickname" placeholder="請輸入昵稱" model:value="{{nickname}}" />
這個方法點擊input框的時候它會彈出你當(dāng)前的微信名稱,基礎(chǔ)庫版本較低的話電腦上無法顯示,只能在真機(jī)調(diào)試上顯示
2,頭像
<button open-type="chooseAvatar" bindchooseavatar="getAvatar">
<image src="{{avatar}}" style="width: 100px;height: 100px;" />
getAvatar(e){
this.setData({
avatar:e.detail.avatarUrl
})
},
點擊按鈕底部彈出自己的頭像,也可以上傳新頭像
返回的e.datail.avatatUrl就是微信頭像的當(dāng)前路徑
效果圖:?文章來源:http://www.zghlxwxcb.cn/news/detail-523133.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-523133.html
到了這里,關(guān)于微信小程序獲取昵稱,頭像的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!