如何限制el-table只能单选

//勾选单行操作
select(selection, row) {
this.multipleSelection=[]; //清空已选
console.log('当用户手动勾选数据行的 Checkbox 时触发的事件', selection, row)
// 选择项大于1时
if (selection.length > 1) {
let del_row = selection.shift();
// console.log('把数组的第一个元素从其中删除后', selection);
this.$refs.multipleTable.toggleRowSelection(del_row, false); // 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)
}
this.multipleSelection.push(selection[0])
console.log('当用户手动勾选数据行', this.multipleSelection)
},

//全选操作
selectAll(selection) {
this.multipleSelection=[]; //清空已选
console.log('当用户手动勾选全选 Checkbox 时触发的事件', selection)
// 选择项大于1时
if (selection.length > 1) {
selection.length = 1;
this.multipleSelection.push(selection[0])
}else{
this.multipleSelection.push(selection[0])
}
console.log('当用户手动勾选全选',this.multipleSelection)
},
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容