this.downloadFile(url);
async downloadFile(url, filename = 'file') {
var debug = url;
if (debug) {
const link = document.createElement('a');
// 这里是将链接地址url转成blob地址,
fetch(url).then(res => res.blob()).then(blob => {
link.href = URL.createObjectURL(blob)
// 下载文件的名称及文件类型后缀
link.download = this.fileOriginalNameLi
document.body.appendChild(link)
link.click()
//在资源下载完成后 清除 占用的缓存资源
window.URL.revokeObjectURL(link.href);
document.body.removeChild(link);
});
} else {
this.$message.error('导出异常请联系管理员');
}
},
01-09
458
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-29
6801
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-29
1447
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-08