后端blob 怎么显示在页面_vue 后端直接返回图片流,前端怎么直接显示在页面上...

ecd92f9e0b72218b0136cc05c652e169.png

我网上搜了一下,说window.URL.createObjectURL(res)可以但是没有效果

fetchData() {

const id = this.$route.query.companyId

getCusInfo(id).then(res => {

const _data = res.data

this.detail = _data

getFileDetail(_data.adAvatar).then(res => {

// const blob = new Blob([res.data], { type: 'image/png' })

// const url = window.URL.createObjectURL(blob)

// this.brandLogoUrl = url

const src = window.URL.createObjectURL(res)

this.brandLogoUrl = src

console.log('res', res)

})

console.log('brandLogoUrl', this.brandLogoUrl)

})

},

class="avatar-uploader"

action="#"

:http-request="advertiserUpload2"

:show-file-list="false"

>

回答

后端设置一下response type就行了,为什么前端要这么麻烦地去处理

直接把 API 地址丢到 src 就可以了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值