新聞動(dòng)態(tài)

位置:首頁(yè) 新聞動(dòng)態(tài) 常見(jiàn)問(wèn)題

uni-app微信小程序獲取用戶頭像并保存

新聞動(dòng)態(tài)
2022年12月09日 閱讀:4799次

methods中使用方法

獲取微信用戶名稱(chēng)
onKeyInput: function(event) {
    this.nickname = event.target.value
},
獲取頭像并且轉(zhuǎn)換成Base64 
onChooseAvatar(e) {
    let imgBase64 = wx.getFileSystemManager().readFileSync(e.detail.avatarUrl, 'base64');
    let background = 'data:image/png;base64,' + imgBase64;
    this.avatarUrl = background
},

上一篇

下一篇