blob 文件下载
axios({
method: 'get',
url:
process.env.VUE_APP_BASE_API +
'/tb-nationwide/downloadEvaluationTaskRecord',
params: param,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token': vue.ls.get(ACCESS_TOKEN),
},
responseType: 'blob',
}).then((res) => {
console.log(res)
const fileName = res.headers['content-disposition']
? window.decodeURI(
res.headers['content-disposition'].split('=')[1],
)
: '渲染全国数据空文件.zip'
const extension = fileName.split('.')[1]
if (extension == 'csv') {
downloader(res.data, fileName)
} else {
downloader(
new Blob([res.data], { type: 'application/' + extension }),
fileName,
)
}
})
downloader为
import downloader from 'downloadjs'