1、為table添加
:header-cell-style="rowClass"
2、通過rowClass 將要跨列的columnIndex 添加屬性 colSpan : 2
被合並的列隱藏
const tableHeaderStyle = {
background: '#305496',
color: '#F8F8FF',
height: '35px',
padding: '2px',
}
const rowClass = ({ column,rowIndex,columnIndex}) =>{
if(rowIndex === 0 && columnIndex === 2){
nextTick(() =>{
document.getElementsByClassName(column.id)[0].setAttribute('colSpan',2);
}) // 一定要寫在加載完畢后,nextTick 更新的最晚,才能獲取到dom節點。
}
if (rowIndex === 0 && columnIndex === 3){
return {display:'none'}
}
return tableHeaderStyle
}
感謝:https://blog.csdn.net/weixin_43842567/article/details/115243092