<template>
//随便搞一个容器
<img id="img1"
:src="imageUrl1"
alt=""
class="img222"
ref="imgDiv"
style="width: 700px; "
/>
</template>
<script>
data(){
return{
imageUrl1:'',
}
}
mounted(){
this.initImage();
}
method(){
initImage(){
this.axios["sxdl-server"]
.request({
url: "/xxx",
method: "post",
data: JSON.stringify({ fileId: this.currentRequestId, filePngPath: this.currentRequestPngPath, fileTiffPath: this.currentRequestTiffPath }),
responseType: "blob",
headers: {
"Content-Type": "application/json;charset=UTF-8",
},
})
.then(function (response) {
var blob = new Blob([response]); //创建一个blob对象
//下面这一行为重点!!!!!!!!!!!!!!!!!!
that.imageUrl1 = window.URL.createObjectURL(blob);
})
.catch(function (err) {
console.log(err);
});
}
}
</script>
<style></style>
从后台拿到图片并展示到页面
最新推荐文章于 2022-10-04 14:42:48 发布