function add0(m) {
return m < 10 ? "0" + m : m;
},
function format() {
//shijianchuo是整数,否则要parseInt转换
var time = new Date();
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
return (
y +
"-" +
add0(m) +
"-" +
add0(d) +
"_" +
add0(h) +
"" +
this.add0(mm) +
"" +
this.add0(s)
);
},
function fileDownload(){
let dataString = format();//获取时间
const blob = new Blob([res.data]);
//兼容IE
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(
blob,
"黄标车限行_" + dataString + ".xlsx"
);
loadingObj.close();
} else {
const a = document.createElement("a");
const href = window.URL.createObjectURL(blob);
a.href = href;
a.download = "黄标车限行_" + dataString + ".xlsx";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(href);
loadingObj.close();
}
}
js文件流下载
最新推荐文章于 2024-04-14 16:44:27 发布