console.log(res.data)
console.log('1',new Uint8Array(res.data))
const C = new Uint8Array(res.data)
console.log(Array.isArray(C),C[0],String.fromCharCode(C[0]))
this.proImg = `data: image/jpeg;base64,${btoa(new Uint8Array(res.data).reduce((data, byte) => data + String.fromCharCode(byte), ''))}`
console.log('1111',this.proImg)
转好了可以在img标签直接使用
第二种方法
const fileStream = res.data;
console.log(fileStream)
// 将文件流转换为Blob对象
const blob = new Blob([fileStream],{ type: 'image/png' });
console.log(blob)
let picUrl = window.URL.createObjectURL(blob)
console.log(picUrl)
转成的 blob:http://localhost:8080/18018aa5-8ed8-4774-aa07-3f4c036fb1ad
可以在img标签中打开也可以在对应浏览器打开