//跨域文件路径、下载到本地的文件名
export const downloadFile = (url, fileName) => {
var x = new XMLHttpRequest();
x.open(“GET”, url, true);
x.responseType = ‘blob’;
x.οnlοad=function(e) {
var url = window.URL.createObjectURL(x.response)
var a = document.createElement(‘a’);
a.href = url
a.download = fileName;
a.click()
}
x.send();
}
js 跨域文件下载
最新推荐文章于 2023-10-23 11:23:17 发布