download (fileUrl, fileName, ext) {
var x = new XMLHttpRequest();
x.open("GET", fileUrl, true);
x.responseType = 'blob';
x.onload = function (e) {
var url = window.URL.createObjectURL(x.response)
var a = document.createElement('a');
a.href = url
a.download = fileName + '.' + ext;
if (ext == 'pdf') {
a.target = '_blank'
a.click()
}
a.click()
}
x.send();
}
跨域下载,a标签download设置下载文件名失效的问题
猜你喜欢
转载自blog.csdn.net/weixin_46210850/article/details/119352791
今日推荐
周排行