關鍵代碼以下html
<el-table ref="multipleTable" :data="tableData" highlight-current-row tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange" @row-click="handleRowClick"> </el-table> <script> export default { methods: { //點擊複選框觸發,複選框樣式的改變 handleSelectionChange(val) { this.multipleSelection = val; }, //點擊行觸發,選中或不選中複選框 handleRowClick(row, column, event){ this.$refs.multipleTable.toggleRowSelection(row); } } } </script>
效果圖以下所示ide