blobToBase64(blob) {
代码语言:javascript复制return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = (e) => {
resolve(e.target.result);
};
fileReader.readAsDataURL(blob);
fileReader.onerror = () => {
reject(newError('文件流异常'));
};
});
},
使用方法:
代码语言:javascript复制this.blobToBase64(file).then(data => {
console.log(data)
}).catch(error => {
console.log(error);
})