vue 根据后端接口导出excel数据

1.导出按钮

  <template #operate="{ scope }">
      <el-button @click="exportExcel(scope.row.id)">导出</el-button>
  </template>

2.导出

    // 点击导出
    exportExcel(id) {
      this.$confirm("此操作将导出excel文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          const link = document.createElement("a");
          link.target = "_blank";
          link.href =
            window.location.origin +
            "/api/bill/excel?id=" +
            id;
          document.body.appendChild(link);
          link.click();
          document.body.removeChild(link);
        })
        .catch(() => {});
    },

猜你喜欢

转载自blog.csdn.net/future_1_/article/details/127850760