element Plus怎么把表头也变为动态的?

image.png

问题1: 就是圈起来的地方怎么也变成动态的,就是label动态
问题2: 点击t-body里的单元格的时候怎么获取到对于的表头

<template>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="name" width="150"></el-table-column>
    <el-table-column prop="date" label="2022-09-25(动态)" width="150">
      <el-table-column prop="state" label="State(动态)" width="120" />
      <el-table-column prop="city" label="City(动态)" width="120" />
      <el-table-column prop="address" label="Address(动态)" />
      <el-table-column prop="zip" label="Zip" width="120" />
    </el-table-column>
    <el-table-column label="2022-09-25">
      <el-table-column prop="state" label="State" width="120" />
      <el-table-column prop="city" label="City" width="120" />
      <el-table-column prop="address" label="Address" />
      <el-table-column prop="zip" label="Zip" width="120" />
    </el-table-column>
  </el-table>
</template>

<script lang="ts" setup>
const tableData = [
  {
    date: '2016-05-03',
    name: '公司1',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036' /*  */,
  },
  {
    date: '2016-05-02',
    name: '公司2',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036',
  },
]

// const renderHeader = ({ column, $index }) => {
//   return <h1>123</h1>
// }
</script>

阅读 2k
1 个回答
<template>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column v-for="column in columns" :prop="column.name" :width="column.width"></el-table-column>
  </el-table>
</template>
....

以上

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题