el-table 去掉全选框
1.el-table中添加header-cell-class-name 表头单元格的 className 的回调方法,给表头全选框添加一个类名
// html
:header-cell-class-name="type === 'REVIEWED' ? cellClass : ''"
// js
cellClass(row) {
if (row.columnIndex === 0) {
return 'disabledCheck'
}
}
// css
/* 去掉全选按钮 */
.el-table__header .disabledCheck .cell {
position: relative;
.el-checkbox {
.el-checkbox__input {
display: none;
}
}
&::before {
// position: absolute;
// z-index: 99999;
content: "";
width: 100%;
height: 100%;
color: #909399;
text-align: center;
}
}
2.样式隐藏
// css
.el-table__header-wrapper .el-table-column--selection {
border: 1px solid #ebeef5;
text-indent: -999999px;
}
3.获取全选框节点删除
// js
this.$nextTick(() => {
const checkboxInput = document.getElementsByClassName('el-checkbox__input')[0]
if (checkboxInput !== undefined) {
checkboxInput.parentNode.removeChild(checkboxInput)
}
})