使用header-cell-class-name 给表头单元格设置一个className用于修改样式:
<el-table
ref="mulChoose"
:data="chooseList"
style="width: 100%"
:row-style="{height:'46px'}"
:cell-style="{padding:'0'}"
:header-cell-class-name="cellClass"
highlight-current-row
height="500"
tooltip-effect="dark"
@select="selectRow">
<el-table-column
type="selection"
width="50">
</el-table-column>
</el-table>
判断是否是表头:
cellClass(row){
console.log(row)
if (row.columnIndex === 0) {
return 'disableSelection'
}
},
添加样式
.el-table .disableSelection .cell .el-checkBox__inner{
display: none;
position: relative;
}
.el-table .disableSelection .cell:before{
content: "";
position: absolute;
// right: 11px;
}
最终实现: