接口獲取文件流VUE轉換為blob展示圖片
接口獲取文件流VUE轉換為blob展示圖片
vue通過接口獲取圖片文件流
<template>
<el-image :src="imgurl" alt="資源訪問失敗" width="80%" height="80%" style="display: block" />
</template>
<script setup>
import axios from "axios";
getimgfileinfo();
async function getimgfileinfo() {
await axios({
method: "post",
url: "http://localhost:8848/api" + props.formData.fileurl.url,//接口地址
params: { key: props.formData.fileurl.params.key, stitle: props.formData.fileurl.params.stitle },//接口參數
responseType: "blob" //接收blob類型
}).then(result => {
console.error(result.data, "result123");
// const qrUrl = window.URL.createObjectURL(new Blob([result.data]));
const qrUrl = window.URL.createObjectURL(result.data);
console.error(qrUrl, "二維碼路徑");
imgurl.value = qrUrl;
});
}
</script>

api接口



參考文獻:https://blog.csdn.net/weixin_69117911/article/details/127716735
本文來自博客園,作者:じ逐夢,轉載請注明原文鏈接:http://www.rzrgm.cn/ZhuMeng-Chao/p/18384112

浙公網安備 33010602011771號