艾尔熙德15 2023-02-27 14:59 采纳率: 0%
浏览 134

vue导出excel如何监听导出成功,增加导出中提示

最近做了一个前端导出的功能,使用的方法是

import FileSaver from "file-saver";
import XLSX from "xlsx";

具体代码是网上找的

    exportToExcel() {
      const XLSX = require("xlsx");
      let fix = document.querySelector(".el-table__fixed");
      let wb;
      if (fix) {
        //判断要导出的节点中是否有fixed的表格,如果有,转换excel时先将该dom移除,然后append回去
        wb = XLSX.utils.table_to_book(
          document.querySelector("#oIncomTable").removeChild(fix)
        );
        document.querySelector("#oIncomTable").appendChild(fix);
      } else {
        wb = XLSX.utils.table_to_book(document.querySelector("#oIncomTable"));
      }
      let wbout = XLSX.write(wb, {
        bookType: "xlsx",
        bookSST: true,
        type: "array",
      });

      try {
        FileSaver.saveAs(
          new Blob([wbout], { type: "application/octet-stream" }),
          "审批列表数据.xlsx"
        );
      } catch (e) {
        if (typeof console !== "undefined") console.log(e, wbout);
      }
      return wbout;
    },

能够成功导出,现在的问题是,没有导出成功的监听方法,想在导出过程中加一个正在导出的loading提示,有没有遇到过类似问题的,求解答

  • 写回答

3条回答 默认 最新

  • 爱的原谅色 2023-02-27 15:06
    关注

    同问,解决了么?

    评论

报告相同问题?

问题事件

  • 创建了问题 2月27日