Vue 讀取后臺(tái)二進(jìn)制文件流轉(zhuǎn)為圖片顯示
后臺(tái)返回格式
<img :src="payImg" id="image" style="width: 150px;height: 150px;" alt="">
axios寫法
重點(diǎn) responseType: ‘blob’ , 使用的是res中的data blob文章來源:http://www.zghlxwxcb.cn/news/detail-848172.html
this.$axios.post('http://116.148.227.196:xxx/api/xxx/xxx', {參數(shù)}, {
responseType: 'blob' // 重點(diǎn)
}).then((res) => {
const url = window.URL.createObjectURL(new Blob([res.data], { type: 'image/png' }));
this.payImg= url;
});
本文章參考 https://huaweicloud.csdn.net/63a56170b878a545459459f2.html文章來源地址http://www.zghlxwxcb.cn/news/detail-848172.html
到了這里,關(guān)于Vue 讀取后臺(tái)二進(jìn)制文件流轉(zhuǎn)為圖片顯示的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!