第一步 把多选框先加上
<el-table v-loading="loading" :data="tableList" class="car-con-table" ref="Table" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="50" align="center" />
</el-table>
第二步 要做单选那就把头部的全选区域隐藏
::v-deep .el-table-column--selection .cell{
display: none;
}
第三步 多选转单选 其实就是每次点多选框的时候 取消上次勾选的 @selection-change
事件
handleSelectionChange(selection) {
if (selection.length > 1) {
this.$refs.Table.clearSelection()
this.$refs.Table.toggleRowSelection(selection.pop())
} else {
this.selection = selection
}
}