
getBase64(data) {
const blob = new Blob([data], { type: "image/jpg" }); //类型一定要写!!!
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onload = () => resolve(reader.result);
reader.onerror = (error) => reject(error);
});
},
调用方法:
const url = "图片地址";
axios
.get(url, {
responseType: "blob", //格式类型!
})
.then((res) => {
console.log('输出二进制流', res.data);
this.getBase64(res.data).then((binary) => {
console.log('', "base64");
});
});
上面是“vue开发如何把二进制流转换为base64”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4103.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

企业网络推广有哪些步骤?
推荐一个免费开源以Bootstrap为主题快速构建web项目——FastBootstrap
新站如何部署关键词进行网站优化?