java后台返回如图:
解决方法:
this.axios
.get("接口地址", {
responseType: "arraybuffer", //重要
params: 传给后端的数据
})
.then(response => {
return (
"data:image/png;base64," +
btoa(
new Uint8Array(response.data).reduce(
(data, byte) => data + String.fromCharCode(byte),
""
)
)
);
})
.then(data => {
this.imgUrl = data; //赋值给img标签的src属性
});
原文链接:https://blog.csdn.net/qq_37628661/article/details/104918677