前端导出表格使用方法

2019-12-21  本文已影响0人  DUREX_ead1

// 导出日志

    async outData() {

      const { data: res } = await this.$http.post(

        "system/handleExportLog",

        qs.stringify(this.logIdsss),

        {

          responseType: "blob"

        }

      );

      console.log(res);

      const link = document.createElement("a");

      let blob = new Blob([res], { type: "application/vnd.ms-excel" });

      link.style.display = "none";

      link.href = URL.createObjectURL(blob);

      let num = "";

      for (let i = 0; i < 10; i++) {

        num += Math.ceil(Math.random() * 10);

      }

      link.setAttribute("download", "操作日志_" + num + ".xlsx");

      document.body.appendChild(link);

      link.click();

      document.body.removeChild(link);

    }

上一篇 下一篇

猜你喜欢

热点阅读