通過iframe進(jìn)行多文件批量下載
///下載方法
async batchDownload() {
for (let i = 0; i < this.fileList.length; i++) {
const res = await downloadClientManuscripts({file_id: this.fileList[i].fileId})
if (res.data) {
this.downloadUrl(res.data.url)
}
}
}
//批量下載
downloadUrl(url) {
const iframe = document.createElement("iframe");
iframe.style.display = "none"; // 防止影響頁(yè)面
iframe.style.height = '0'; //防止影響頁(yè)面
iframe.src = url;
document.body.appendChild(iframe); // 這一行必須,iframe掛在到dom樹上才會(huì)發(fā)請(qǐng)求
setTimeout(function () {
iframe.remove();
}, 5 * 60 * 1000);
}