Vue操作:导出csv文件
参考:https://www.cnblogs.com/libinfs/p/8080985.htmllet data = res.data;//csv数据let filename = main.label + ".csv";//导出的文件名let type = "";//头部数据类型let file = new Blob(...
·
参考:https://www.cnblogs.com/libinfs/p/8080985.html
let data = res.data; //csv数据
let filename = main.label + ".csv"; //导出的文件名
let type = ""; //头部数据类型
let file = new Blob(["\ufeff" + data], { type: type });
if (window.navigator.msSaveOrOpenBlob)
// IE10+
window.navigator.msSaveOrOpenBlob(file, filename);
else {
// Others
let a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}
调用或封装成函数可下载csv文件
更多推荐
已为社区贡献4条内容
所有评论(0)