话不多说,上代码
<template>
<div>
<img
:src="imgSrc"
alt=""
>
</div>
</template>
<script>
export default {
data(){
return {
imgSrc: '',
}
},
created() {
getImg(this.$route.params.id).then(res => {
const blob = new Blob([res],{type:'image/png'})
const url = windows.URL.creatObjectURL(blob)
this.imgSrc = url
}
}
}
</script>
this.imgSrc 数据格式:
["bobl:http//localhose:8080/******"]
接口设置:
export function downFile(url) {
return request({
url:url,
method: 'get',
responseType:'blob'
})
}
expost const getImg = (id) => downFile(`地址${id}`)