template:
<el-table ref="equipment" highlight-current-row :data="equipmentList" stripe @selection-change="handleSelectionChange" @current-change="row => $refs.equipment.toggleRowSelection(row)">
.....
</el-table>
methods:
// 单选框选中数据
handleSelectionChange(selection) {
if (!selection[0]) {
this.form.code = ''
this.form.name = ''
}
this.currentRow = selection[0] || {};
if (selection.length > 1) {
this.$refs.equipment.clearSelection();
this.$refs.equipment.toggleRowSelection(selection.pop());
}
},
CSS:
<style lang="scss" scoped>
::v-deep {
.el-table__header .el-checkbox{
display:none!important;
}
.el-table__header-wrapper .el-table-column--selection.el-table__cell .cell:before {
content: "单选";
}
}
</style>
效果: