blob和ArrayBuffer格式图片如何显示
首先blob格式图片
<template> <div> <img :src="imageURL" alt="Image" /> </div>
</template> <script>
export default { data() { return { imageBlob: null, // Blob格式的图片 imageURL: null // 图片的URL }; }, async mounted() { // 获取Blob格式的图片 // ... // 将Blob格式的图片转换为可访问的URL const objectURL = URL.createObjectURL(this.imageBlob); this.imageURL = objectURL; }
};
</script>
ArrayBuffer
let blob = new Blob( [res.data], {type:'application/vnd.ms-excel;charset=utf-8'} );
let imgUrl = URL.createObjectURL(res.data)