zip 文件下载函数封装

代码:

export default {
    /**
     * 下载文件
     */
    exportFile: (fileUrl) => {
        if (fileUrl) {
            let exportFrame = document.querySelector("#exportFrame");
            if (exportFrame) {
                document.body.removeChild(exportFrame);
            }

            exportFrame = document.createElement("iframe");
            exportFrame.id = "exportFrame";
            exportFrame.style.cssText = "display: none";

            exportFrame.onload = function() {
                document.body.removeChild(exportFrame);
            }

            exportFrame.src = fileUrl;
            document.body.appendChild(exportFrame);
        }
    }
}

.

posted @ 2019-02-26 22:32  每天都要进步一点点  阅读(208)  评论(0编辑  收藏  举报