plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
745 B

2 years ago
  1. function handleExport(data) {
  2. // 动态创建iframe下载文件
  3. let fileName = this.selectedTabelRow[0].dirName;
  4. if (!data) {
  5. return;
  6. }
  7. let blob = new Blob([data], { type: "application/octet-stream" });
  8. if ("download" in document.createElement("a")) {
  9. // 不是IE浏览器
  10. let url = window.URL.createObjectURL(blob);
  11. let link = document.createElement("a");
  12. link.style.display = "none";
  13. link.href = url;
  14. link.setAttribute("download", fileName);
  15. document.body.appendChild(link);
  16. link.click();
  17. document.body.removeChild(link); // 下载完成移除元素
  18. window.URL.revokeObjectURL(url); // 释放掉blob对象
  19. } else {
  20. // IE 10+
  21. window.navigator.msSaveBlob(blob, fileName);
  22. }
  23. }