element UI 表格單擊行時選中該行 checkBox

唏嘘-發表於2024-07-01
1、table上增加 @row-click="handleClickTableRow"
2、單選框的checkbox那列加上  @selection-change="handleSelectionChange"
3、table加上ref
程式碼實現:
methods: {
    handleClickTableRow(row, event, column) {
      console.log(row);
      console.log(column);
      this.$refs.fileTable.toggleRowSelection(row);
    },
    handleSelectionChange(rows) {
      console.log(rows);
      this.multipleSelection = rows;
    },
},

 

相關文章