1

我正在使用 JSZIP 批量下载 pdf 文件,但它一直返回以下错误 Uncaught (in promise) TypeError: zip.generateAsync is not a function(...) Download.js:223 有人知道为什么吗?

这是我的语法:

doDownload : function() {

//TEST BEGIN to 

var urls = [];

var  rc = this.getRowsAndColumns();
console.dir(rc)

for (var i=0, il = rc.rows.length; i<il;i++){
    var url = rc.rows[i].requ;

    if(!urls.includes(url))
        urls.push(url);
}

/*
for (var i=0, il = obj.length; i<il;i++){

var obj = resultmap[i].attributes.requ;

    urls.push(obj);

}
*/
console.dir(urls)


      var zip = new JSZip();
      console.log("zip = "+zip);
      var a = document.getElementById("downloadZipLink");


      function request(url) {
        return new Promise(function(resolve) {
          var httpRequest = new XMLHttpRequest();
          httpRequest.open("GET", url);
          httpRequest.onload = function() {
            zip.file(url, this.responseText);
            resolve()
          }
          httpRequest.send()
        })
      }

      Promise.all(urls.map(function(url) {
          return request(url)
        }))
        .then(function() {
          console.log(zip);
          zip.generateAsync({
              type: "blob"
            })
            .then(function(content) {
              a.download = "folder" + new Date().getTime();
              a.href = URL.createObjectURL(content);
              a.innerHTML = "download " + a.download;
            });
        })

      },

详细信息在以下链接中:

https://github.com/cici004/SMILE-Tes​​t

4

0 回答 0