exportCommont(res) {
// 创建一个新的url,此url指向新建的Blob对象
const url = window.URL.createObjectURL(new Blob([res.data]));
// 创建a标签,并隐藏改a标签
const link = document.createElement('a');
link.style.display = 'none';
// a标签的href属性指定下载链接
link.href = url;
let fileName = res.headers['content-disposition'].split('filename=')[1];
fileName = fileName.substring(0, fileName.length);
fileName = decodeURIComponent(decodeURIComponent(fileName));
// const fileName = `${this.dateVal}功率预测曲线.xlsx`;moment
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
this.$message.success('导出成功');
}
文件导出封装
最新推荐文章于 2024-09-15 10:33:02 发布