elementui 动态table表头

<el-table
      size="mini"
      :stripe="false"
      :header-cell-style="{'background':'#d3e0ff'}"
      :row-class-name="rowClass"
      :data="tableData"
      :span-method="objectSpanMethod"
      border
      style="width: 100%; margin-top: 20px">
      <template v-for="item in tableHeader">
        <el-table-column
            :fixed="item.key == 'itemNo' || item.key == 'itemName' || item.key == 'amount'"
            :key="item.key"
            :label="item.label"
            align="center">
          <template slot-scope="scope">
              <span>{{ scope.row[item.key] }}</span>
          </template>
        </el-table-column>
      </template>
    </el-table>
<script>
export default {
    data() {
      return {
        tableHeader:[{
            label:'项目编号',
            key:'itemNo'
        },......],
      };
    },
}
</script>    

 

posted @ 2023-01-06 09:48  秃头的铲屎官  Views(580)  Comments(0Edit  收藏  举报