el-table el-table-column表头嵌套循环数据

需求:

不同以前 现在需要表头嵌套循环 以前只要

复制代码
 <template>
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="date"
        label="日期"
        width="180">
      </el-table-column>
    </el-table>
  </template>

 data() {
        return {
          tableData: [{
            date: '2016-05-02',
            name: '王小虎',
            address: '上海市普陀区金沙江路 1518 弄'
          }]
        }
      }

现在需要表头嵌套循环:思路,两个数组,一个数组循环表格数据,一个循环表头

复制代码
<el-table
        ref="pageTable"
        :data="tableData"
        style="margin-top: 15px"
        height="548"
        :header-cell-style="cellStyleFun"
        id="out-table2"
      >
        <el-table-column
          fixed
          label="管辖单位"
          prop="C_NAME"
          :formatter="fmtTableProp"
          align="center"
          width="230"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              style="white-space: pre-wrap"
              @click="detailTree(scope.row)"
              >{{ scope.row.C_NAME }}</el-button
            >
          </template>
        </el-table-column>
        <el-table-column
          v-for="item in tableHeaderData" //单独循环表头-普通循环
          :key="item"
          :label="item"
          align="center"
          width="140"
        >
          <el-table-column
            label="登录次数"
            prop="LOGIN_COUNT"
            align="center"
            width="140"
          >
            <template slot-scope="scope">
              <span>{{ scope.row[item].LOGIN_COUNT }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="检查次数"
            prop="CHECK_COUNT"
            align="center"
            width="140"
          >
            <template slot-scope="scope">
              <span>{{ scope.row[item].CHECK_COUNT }}</span>
            </template>
          </el-table-column>
        </el-table-column>
      </el-table>

js:
tableHeaderData: [], // 头部列表数据
tableData: [], // 列表数据

searchFun() {
      this.loading = true;
      const param = this.paramSet();
      workStatisticsByGx(param).then((data) => {
        this.loading = false;
        if (data.data && data.data.code == 10000) {
          this.tableHeaderData = data.data.otherObj;//表头时间
          this.tableData = data.data.obj;//表格数据
        } else {
          this.$confirm(data.data.message || "服务器忙", "提示", {
            type: "warning",
            center: true,
            customClass: "warn-dialog",
          })
            .then(() => {})
            .catch(() => {});
        }
      });
    },
相关推荐
dorisrv7 分钟前
优雅的React表单状态管理
前端
蓝瑟25 分钟前
告别重复造轮子!业务组件多场景复用实战指南
前端·javascript·设计模式
老华带你飞27 分钟前
旅游|基于Java旅游信息系统(源码+数据库+文档)
java·开发语言·数据库·vue.js·spring boot·旅游
dorisrv1 小时前
高性能的懒加载与无限滚动实现
前端
韭菜炒大葱1 小时前
别等了!用 Vue 3 让 AI 边想边说,字字蹦到你脸上
前端·vue.js·aigc
StarkCoder1 小时前
求求你,别在 Swift 协程开头写 guard let self = self 了!
前端
清妍_1 小时前
一文详解 Taro / 小程序 IntersectionObserver 参数
前端
电商API大数据接口开发Cris1 小时前
构建异步任务队列:高效批量化获取淘宝关键词搜索结果的实践
前端·数据挖掘·api
符方昊1 小时前
如何实现一个MCP服务器
前端
喝咖啡的女孩1 小时前
React useState 解读
前端