批量下载文件,循环使用window.open(url) 的方式会打开新页签,参考了一位大侠的文章,使用iframe可以的: https://blog.csdn.net/nanke_yh/article/details/125145717
如下:
fileList.forEach(file => { //同时下载多个文件,使用iframe下载,因为window.open或者a都会被拦截 const url = file.url + "?attname=" + file.name; let iframe = document.createElement('iframe'); iframe.id = file.id; iframe.style.display = "none"; document.body.appendChild(iframe); iframe.src = url; setTimeout(() => { document.body.removeChild(iframe); }, 100); })
标签:iframe,新页,url,window,file,document,open From: https://www.cnblogs.com/nanamiao/p/18047320