1 首先隐藏掉多选checkbox
.custom-data /deep/ .el-table__header-wrapper .el-checkbox{
display: none;
}
2 利用table 的selection-change 事件实现单选
<template>
<el-table class="custom-table" ref='simpleTable' @selection-change="handleSelectionChange">
</el-table>
</template>
data(){
return {
multipleSelection:[]
}
},
methods:{
handleSelectionChange(val){
if (val.length > 1) {
this.$refs.simpleTable.clearSelection()
this.$refs.simpleTable.toggleRowSelection(val.pop())
}
this.multipleSelection = val;
},
}
效果: