获得徽章 0
- 文件批量下载,el-table多选后得到数组列表,点击批量下载按钮执行。const elements = this.selectedDataList.map((item, index) => {
let a = document.createElement("a");
a.download = "";
a.href = this.selectedDataList[index].downloadPath;
return a;
})
// 当前下载的文件是第几个
let index = 0;
// 定时器的回调函数
function download(index) {
const aElement = elements[index];
if (aElement.href) {
aElement.click();
}
index = index + 1;
if (index < elements.length) {
setTimeout(download, 1000, index);
}
}
// 启动下载
setTimeout(download, 0, index);展开42