btnOutClick(){
this.api({
url: '/main/excel',
responseType:"blob",
method: 'get'
}).then(response=>{
console.log(response)
const res = response.data
if (response.headers['content-type'] === "application/octet-stream;charset=utf-8") {
let disposition = decodeURI(response.headers['content-disposition']);
let fileName = disposition.split('=')[1];
const a = document.createElement('a')
const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
const url = URL.createObjectURL(blob)
a.setAttribute('href', url)
a.setAttribute('download', fileName)
a.click()
return
}
})}
vue得到后端二进制流下载excel文件
最新推荐文章于 2023-08-31 09:16:30 发布