带复选框的单选表格
<el-table
:data="tableData"
@current-change="handleSelectionChange"
@select="selectSingleTable"
ref="singleTable"
highlight-current-row
border
stripe
style="width: 100%;"
>
<el-table-column type="index" width="50"></el-table-column>
<el-table-column type="selection" width="55"></el-table-column>
</el-table>
// 单选
handleSelectionChange(val) {
this.choserow = val;
this.$refs.singleTable.clearSelection();
this.$refs.singleTable.toggleRowSelection(val, true);
},
selectSingleTable(selection, row) {
if (selection.length > 0) {
this.$refs.singleTable.setCurrentRow(row);
this.$refs.singleTable.clearSelection();
this.$refs.singleTable.toggleRowSelection(row, true);
this.choserow = row;
} else {
this.choserow = null;
this.$refs.singleTable.setCurrentRow([]);
this.$refs.singleTable.clearSelection();
}
},
网友评论