zhiyong.zhou
2024-02-26 60d911172b1dbebe0ab952ce10366b327d5744f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 导出的流Blob,filename 导出的文件名
export function downloadFileBlob(data,filename) {
    if (!data) {
          return
      }
      let url = window.URL.createObjectURL(new Blob([data]))
      let link = document.createElement('a')
      link.style.display = 'none'
      link.href = url
      link.setAttribute('download', filename)
  
      document.body.appendChild(link)
      link.click()
  }
  // 用a链接导出处理方案GET方式
  export function downloadALink(url,filename){
    var a = document.createElement('a');
    a.setAttribute('href', url);
    a.setAttribute('target', '_blank');
    a.setAttribute('download', filename);
    a.setAttribute('id', 'startTelMedicine');
    // 防止反复添加
    if(document.getElementById('startTelMedicine')) {
      document.body.removeChild(document.getElementById('startTelMedicine'));
    }
    document.body.appendChild(a);
    a.click();
  }