使用Blob对象接收后台返回的图片流并展示到前端页面

使用Blob对象接收后台返回的图片流并展示到前端页面

一、效果图

在这里插入图片描述

二、主要代码

export function 接口(params) {
    return request({
        url: `urlurlurl`,
        method: 'get',
        params,
        responseType: 'blob',
        isExport: true,
    })
}
<img
     style="width: 170px; height: 117px; border-radius: 10px"
     :src="businessLicenseUrl"
     class="avatar"
 />
接口(参数).then(res => {
    this.businessLicenseUrl = window.URL.createObjectURL(res.data)
    //businessLicenseUrl就是blob对象
    //:blob:http://localhost:8080/5a5a092a-93c8-4ba8-9918-4329b112a2ec
})

版权声明:本文为MISS_zhang_0110原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。