table上加上
<el-table :header-cell-class-name="changeHeaderRow">
let num=3 //合并数
let colIndex=10 //起始列
modifyWindowTableHeader() {
// 将第一列表头单元格的colSpan设为合并格数
document.querySelector('.colSpan').colSpan = num
// 将第二列表头单元格的隐藏
document.querySelectorAll('.hideTh').forEach(v => {
v.style.display = 'none'
})
},
changeHeaderRow({ row, column, rowIndex, columnIndex }) {
if (rowIndex === 0) {
// 给第一列表头的dom添加class='colSpan'
if (columnIndex === colIndex) {
return 'colSpan'
}
// 给第二列表头的dom添加class='hideTh'
if (columnIndex>colIndex&columnIndex<(colIndex+num)) {
return 'hideTh'
}
}
},