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属性
})
vue+axios将后端返回的图片流显示到img中
最新推荐文章于 2023-06-08 09:03:51 发布