我遇到一种情况,我需要一键单击来模拟几个下载请求。我的代码在这里:
download(filename: string) {
console.log(filename);
const href = <my href>;
let a = document.createElement('a');
a.setAttribute('style', 'display: none');
a.href = href;
a.download = filename;
a.click();
a.remove();
}
downloadFiles(className) {
for (let docLink of this.component.nativeElement.getElementsByClassName(className)) {
docLink.click();
}
}
但是这里的问题是文件下载仅针对一个文件而不是3启动。