href不会循环下载文件

时间:2019-04-10 20:40:20

标签: javascript html

我遇到一种情况,我需要一键单击来模拟几个下载请求。我的代码在这里:

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启动。

0 个答案:

没有答案