element table多选和单选
多选
<el-table :data="tableData" border @selection-change="handleSelectionChange">
<el-table-column type="selection" width="40px" :selectable="handleDisable"></el-table-column>
如果有条件判断是否可勾选:
handleDisable(row,index){
//返回true或false
},
handleSelectionChange(val){
this.chek = val;
},
单选
<el-table :data="tableData" border @selection-change="handleSelectionChange" ref="tb" @select-all="onSelectAll">
<el-table-column type="selection" width="40px"></el-table-column>
handleSelectionChange(val){
if(val.length > 1){
this.$refs.tb.clearSelection()
this.$refs.tb.toggleRowSelection(val.pop())
}else{
this.chek = val;
}
},
onSelectAll () {
this.$refs.tb.clearSelection()
},