1、template模板的el-table标签中定义class名和选择方法(handleSelection)
<el-table ref="list" v-loading="crud.loading" class="columnTable" :data="crud.data" size="small" style="width: 100%;" @sort-change="crud.changeTableSort" @select="handleSelection">
<el-table-column type="selection" width="45" >
</el-table-column>
...
</el-table>
2、增加样式
.columnTable /deep/ thead th .el-checkbox{
visibility: hidden;
}
</style>
3、增加方法
methods: {
handleSelection(selection,row){
if(selection.length === 1){
const selectObj = row
this.$emit('event1', selectObj)
}else{
this.$refs.list.clearSelection() //先清空选中状态,selection值还在
this.$refs.list.toggleRowSelection(selection.pop())
const selectObj = row
this.$emit('event1', selectObj)
}
},