handleSelectionChange(selection) { if(selection.length > 1){ this.$refs.table.clearSelection() this.$refs.table.toggleRowSelection(_el-table单选禁掉全选的按钮">
赞
踩
1.多选变单选方案:
<el-table ref="table" @selection-change="handleSelectionChange">
</el-table>
handleSelectionChange(selection) {
if(selection.length > 1){
this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(selection.pop())
}
},
2.隐藏全选框
html
<el-table
v-loading="loading"
ref="table"
@selection-change="handleSelectionChange"
:header-cell-class-name="cellClass"
>
js
cellClass(row){
if (row.columnIndex === 0&&this.fromTag == 'dialog') {
return 'disabledCheck'
}
}
css样式
/* 去掉全选按钮 */
::v-deep .el-table .disabledCheck .cell .el-checkbox__inner{
display: none;
}
::v-deep .el-table .disabledCheck .cell::before{
content: '选择';
text-align: center;
line-height: 37px;
}
参靠:https://www.cnblogs.com/JinXinYuan/p/12165027.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。