Table header merging in Element UI

achieve the above effects

There is an attribute header-cell-style attribute in el-table: used to set the style of the header cell

code show as below:

<el-table class="state-table" :data="temHoleTableData"
          size="mini" style="width: 100%" height="100%" :header-cell-style="headerStyle">
  <el-table-column prop="project" label="内圈" align="center" width="75"/>
  <el-table-column prop="project" label="中圈" align="center" width="75"/>
  <el-table-column prop="project" label="外圈" align="center"/>
  <el-table-column prop="project" label="外圈" align="center"/>
  <el-table-column prop="project" label="外圈" align="center"/>
</el-table>

headerStyle({row, column, rowIndex, columnIndex}) {
  row[2].colSpan = 3 //The header of the third column occupies 3 cells
  row[3].colSpan = 0
  row[4].colSpan = 0
  if (columnIndex === 3 || columnIndex === 4) {
    return 'display: none'
  }
}

Guess you like

Origin blog.csdn.net/workhard0905/article/details/124403080