前端获取流:
接口路径:
api = {
download: ip + 'jobs/export', // 下载
};
<i class="el-icon-download icon" @click="download(scope.row)"></i>
download(item) {
var a = document.createElement('a');
a.href = `${api.download}/${item.name}`;
a.download = item.name;
a.click();
},
通过发送axios请求向后台获取文档流
// 下载
download(item) {
this.axios.get(api.download+'/'+item.name,{responseType:"blob"}).then(res => {
// console.log(res)
let bob = new Blob([res.data],{type: 'application/vnd.ms-excel'})
const link = document.createElement('a');
let url = window.URL.createObjectURL(bob);
link.download = '影像迁移日志列表.xlsx';
link.href = url;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
})
},