vue批量下载
handleAllDown() {
const fileList = this.fileList;
if (fileList.length) {
for (let i = 0; i < fileList.length; i++) {
if (fileList[i].name) {
this.downloadFile(fileList[i].name)
}
}
}
},
// 批量下载
downloadFile(url) {
const iframe = document.createElement("iframe");
const tenantId = this.$store.state.tenant.tenantId
iframe.style.display = "none"; // 防止影响页面
iframe.style.height = 0; // 防止影响页面
iframe.src = location.origin + process.env.VUE_APP_BASE_API + `/trade/payPersonalIncomeTax/receipts/${tenantId}?fileName=${url}&month=${this.month}&id=${this.id}`;
document.body.appendChild(iframe); // 这一行必须,iframe挂在到dom树上才会发请求
// 5分钟之后删除(onload方法对于下载链接不起作用,就先抠脚一下吧)
setTimeout(() => {
iframe.remove();
}, 5 * 60 * 1000);
},
网友评论