我网上搜了一下,说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 就可以了。