window.open下载文件如何重命名
window.open下载文件如何重命名
·
download(url, fileName ) {
let self = this;
const url = url
let x = new XMLHttpRequest();
x.open("GET", url, true);
x.responseType = "blob";
x.onload = function() {
//self.exportLoading = false;
let url = window.URL.createObjectURL(x.response);
let a = document.createElement("a");
a.href = url;
a.download = fileName;
a.click();
};
x.send();
}
在页面这样使用
download(url, ’文件名字‘)
更多推荐
已为社区贡献2条内容
所有评论(0)