浏览器的安全机制决定着 不能短时间内打开多个新的空白窗口
但是一般下载都是需要打开新的窗口,多个下载就需要快速打开多个新的窗口
所以就需要另辟蹊径
// 获取总的url
let urlarr = ['https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/source/apache-maven-3.6.3-src.zip', 'https://nodejs.org/dist/latest-v10.x/node-v10.23.0-headers.tar.xz']
// 打开url
function openUrl(url) {
window.location.href = url
}
// 单个下载满足条件 以及不满足条件
var fileindex = 0
function handledown() {
console.log(fileindex)
if (fileindex == urlarr.length) {
clearInterval(cancel)
} else {
openUrl(urlarr[fileindex]);
fileindex += 1
}
}
// 批量执行
var cancel = setInterval(handledown, 500)