问题描述
后台返回的乱码(get请求)
this.$api.danger
.getDownloadVersion({
path:this.downPath,
responseType:'blob'
})
.then(res=> {
leta=document.createElement('a')
letblob=newBlob([res], {
type:'application/octet-stream'
})
// 创建下载的链接
letobjectUrl=URL.createObjectURL(blob)
a.setAttribute('href',objectUrl)
// 下载文件名和文件类型
a.setAttribute('download',this.downPath)
// 点击下载
a.click()
// 下载完成移除元素
document.body.removeChild(a)
// 释放掉blob对象
URL.revokeObjectURL(objectUrl)
})
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
3 回答5.1k 阅读✓ 已解决
3 回答1.8k 阅读✓ 已解决
这个是后台没有正常的返回 content-type 吧..