vue项目中一次下载多个文件的js实现

  • 下载多文件时,将需要下载的文件的地址放到一个数组内,代码如下:
allLoad() {
  for(let i=0;i<this.fileList.length;i++){
     const iframe = document.createElement("iframe");
     iframe.style.display = "none"; // 防止影响页面
     iframe.style.height = 0; // 防止影响页面
     iframe.src = this.fileList[i]; 
     document.body.appendChild(iframe); // 这一行必须,iframe挂在到dom树上才会发请求
     // 5分钟之后删除
     setTimeout(()=>{
        iframe.remove();
      }, 5 * 60 * 1000);
  }
}

猜你喜欢

转载自blog.csdn.net/weixin_38131507/article/details/114590480