您好!我按着您的帖子改的代码块如下,点击后仍然只下载了最后一个文件,想请教您一下,感谢!
handleDownload(row) {
var name = '';
var url = row;
var suffix = url.substring(url.lastIndexOf("."), url.length);
const a = document.createElement("a");
a.setAttribute("download", name + suffix);
a.setAttribute("target", "_blank");
a.setAttribute("href", url);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
},
downloadAllFile(){
var files = [];
const delay = 1000;
for( var j in this.allFileInfoList ){
// var row = {
// fileName: this.allFileInfoList[j].fileName,
// filePath: this.allFileInfoList[j].filePath
// };
files.push(this.allFileInfoList[j].filePath);
};
files.forEach( (item, index) => {
setTimeout( () => {
this.handleDownload(item);
}, delay * index);
});
},