uni.chooseImage({
count: 9,
success: res => {
this.imageList = this.imageList.concat(res.tempFilePaths);
console.log(res);
// this.tempFilePaths = res.tempFilePaths[0];
var base64 = this.urlTobase64(res.tempFilePaths[0]);
}
});
转base64码
urlTobase64(url) {
uni.request({
url: url,
method: ‘GET‘,
responseType: ‘arraybuffer‘,
success: res => {
let base64 = wx.arrayBufferToBase64(res.data); //把arraybuffer转成base64
base64 = ‘data:image/jpeg;base64,‘ + base64; //不加上这串字符,在页面无法显示
return base64
}
});
},
原文地址:https://www.cnblogs.com/landuo629/p/12871819.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。