使用 jszip.js npm,zip.generateAsync 反应重新渲染问题

时间:2020-12-30 11:45:18

标签: reactjs client-server ziparchive jszip

我使用以下代码下载 zip 文件。 下载了 zip 文件,但会导致应用程序无法控制地重新呈现。 谁能帮我解决这个问题。

        let zipFilename = "Douments.zip";
        downloadUrls.forEach((url, index) => {
            // loading a file and add it in a zip file
            JSZipUtils.getBinaryContent(url.url, (err, data) => {
                if (err) {
                    throw err; // or handle the error
                }
                let date = new Date()
                zip.file(url.fileName, data, { binary: true });
                count++;
                if (count === downloadUrls.length) {
                    zip.generateAsync({ type: 'blob' }).then((content) => {
                        FileSaver.saveAs(content, zipFilename);
                        console.log("trigger", content)
                    });
                }
            });
        })```

0 个答案:

没有答案