# el-tab点击行时选中复选框

在 el-table 部分加上 @row-click 和 ref

 <el-table
           ref="ShopTableRef"
           tooltip-effect="dark"
           :data="tableData"
           style="width:100%"
           height="500"
           @selection-change="handleSelectionChange"
           @row-click="handleRowClick"
           v-loading="loading"
           >
1
2
3
4
5
6
7
8
9
10

实现方法

    //点击复选框触发,复选框样式的改变
    handleSelectionChange(val) {
        this.multipleSelection = val;
    },
    //点击行触发,选中或不选中复选框
   	handleRowClick(row, column, event) {
        this.$refs.ShopTableRef.toggleRowSelection(row);
        // console.log("this.selecTestContent", this.selectTestContent);
    },
1
2
3
4
5
6
7
8
9
上次更新: 2020/10/23 下午7:23:27