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);
           }
    
  • 相关阅读:
    修改spring boot 启动logo
    查看jvm常用命令
    intellij IDEA破解
    hdu 新生晚会
    How many prime numbers(素数)
    2077 汉诺塔IV
    Factorial
    双人黑白块
    EasyX
    七夕情人节
  • 原文地址:https://www.cnblogs.com/33shan/p/15250384.html
Copyright © 2011-2022 走看看