js 下载

作者: 殇城阡陌 | 来源:发表于2020-06-10 16:08 被阅读0次

    // 单个文件下载

        // 组装a标签

            let elink = document.createElement("a");

            // 设置下载文件名

            elink.style.display = "none";

            elink.href =

              window.API_MODULES.public +

              `/inst/data/download/part?token=${encodeURIComponent(

                token

              )}&partName=${encodeURIComponent(item)}`;

            document.body.appendChild(elink);

            elink.click();

            document.body.removeChild(elink);

            // 多个文件下载

            let adress =

              window.API_MODULES.public +

              `/inst/data/download/part?token=${encodeURIComponent(

                token

              )}&partName=${encodeURIComponent(item)}`;

            setTimeout(function() {

              let frame = document.createElement("iframe");

              frame.setAttribute("id", "iframe_" + i);

              frame.src = adress;

              document.body.appendChild(frame);

              setTimeout(function() {

                document.body.removeChild(frame);

              }, 1000);

            }, 100);

    相关文章

      网友评论

          本文标题:js 下载

          本文链接:https://www.haomeiwen.com/subject/xajptktx.html