uni-app 图片转base64

urlTobase64(url) {
var toBase64Url;
uni.request({
url: url,
method: ‘GET‘,
responseType: ‘arraybuffer‘,
success: async res => {
let base64 = wx.arrayBufferToBase64(res.data); //把arraybuffer转成base64
toBase64Url = ‘data:image/jpeg;base64,‘ + base64; //不加上这串字符,在页面无法显示
console.log(toBase64Url);
}
});
}

let coverImg:‘https://img-cdn-qiniu.dcloud.net.cn/uploads/avatar/000/51/83/99_avatar_max.jpg‘

this.urlTobase64(coverImg);

 

uni-app 图片转base64

上一篇:283. 移动零


下一篇:手机商品分享样式(纯html+css)