zoukankan      html  css  js  c++  java
  • 多个文件下载

            this.file_url = ["http://123", "http://1234", "http://1235"];//文件地址
            // a链接版本--下载文件
            for (let i = 0; i < this.file_url.length; i++) {
              let url = window.URL.createObjectURL(new Blob([this.file_url[i]]));
              let link = document.createElement("a");
              link.style.display = "none";
              link.href = url;
              let fileName = this.file_url[i].substring(
                this.file_url[i].lastIndexOf("/") + 1,
                this.file_url[i].length
              );
              link.setAttribute("download", fileName);
              document.body.appendChild(link);
              link.click();
            }
    
            // iframe版本--下载文件
            for (let i = 0; i < this.file_url.length; i++) {
              const iframe = document.createElement("iframe");
              iframe.style.display = "none"; // 防止影响页面
              iframe.style.height = 0; // 防止影响页面
              iframe.src = this.file_url[i]; // url自己进行指定
              document.body.appendChild(iframe); // 这一行必须,iframe挂在到dom树上才会发请求
              setTimeout(() => {
                iframe.remove(); // 5分钟之后删除
              }, 5 * 60 * 1000);
           }
    
  • 相关阅读:
    Python(4)
    docker-数据管理(3)
    docker(2)
    docker(1)
    ansible的role(6)
    windows实用cmd命令总结
    Orcal数据类型总结
    Orcal设置默认插入数据的日期和时间
    linux常用关机和重启命令
    electron关于页面跳转 的问题
  • 原文地址:https://www.cnblogs.com/33shan/p/15250384.html
Copyright © 2011-2022 走看看