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(() => {});
        }
      });
    },
相关推荐
IT_陈寒20 分钟前
Python开发者必知的5大性能陷阱:90%的人都踩过的坑!
前端·人工智能·后端
codingWhat1 小时前
介绍一个手势识别库——AlloyFinger
前端·javascript·vue.js
Lee川1 小时前
深度拆解:基于面向对象思维的“就地编辑”组件全模块解析
javascript·架构
代码老中医1 小时前
2026年CSS彻底疯了:这6个新特性让我删掉了三分之一JS代码
前端
进击的尘埃1 小时前
Web Worker 与 OffscreenCanvas:把主线程从重活里解放出来
javascript
不会敲代码11 小时前
Zustand:轻量级状态管理,从入门到实践
前端·typescript
踩着两条虫1 小时前
VTJ.PRO 双向代码转换原理揭秘
前端·vue.js·人工智能
扉川川1 小时前
OpenClaw 架构解析:一个生产级 AI Agent 是如何设计的
前端·人工智能
远山枫谷1 小时前
一文理清页面/组件通信与 Store 全局状态管理
前端·微信小程序
codingWhat1 小时前
手撸一个「能打」的 React Table 组件
前端·javascript·react.js