vue 处理后端返回的png图片,并在页面上显示
后端返回的png格式,不能直接在页面显示
<div class="input-group-addon image-code" @click="generateImageCode()"><img :src=imageCode alt=""></div>
打印后端返回的png则是二进制
如何解决呢?把response-type改为blob类型
httpClient.get(common.k8sGetImageCode + "/" + this.imageCodeId,{responseType:"blob"}).then(
res => {
//
let blob = new Blob([res]);
let url = window.URL.createObjectURL(blob);
this.imageCode = url
// console.log(url)
}
)