blobToBase64(blob) {

return new Promise((resolve, reject) => {
  const fileReader = new FileReader();
  fileReader.onload = (e) => {
    resolve(e.target.result);
  };
  fileReader.readAsDataURL(blob);
  fileReader.onerror = () => {
    reject(newError('文件流异常'));
  };
});

},

使用方法:

this.blobToBase64(file).then(data => {
  console.log(data)
}).catch(error => {
  console.log(error);
})

标签: none

添加新评论