element ui Table 如何取消表格选中状态

清除单个选项:

toggleRowSelection: 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)

参数,toggleRowSelection。方法中传入想要清除的行的数据即可。

<el-table ref="multipleTable" @row-click="handleRowClick" :data="saleMaterialList" :row-key="getRowKeys" border
  @selection-change="selectionChange">
  <el-table-column type="selection" reserve-selection width="55"></el-table-column>
  <el-table-column prop="materialName" label="物料名称"> </el-table-column>
  <el-table-column prop="materialModel" label="规格型号"> </el-table-column>
  <el-table-column prop="materialRate" label="系数比重"> </el-table-column>
  <el-table-column prop="materialUnit" label="单位"> </el-table-column>
</el-table>
handleRowClick (row, column, event) {
    
    
   this.$refs.multipleTable.toggleRowSelection(row);
},

有一种场景如下:

先选中一部分数据,然后点击某个人按钮去做操作,但是操作之前需要排除掉一部分选中数据:
this.$refs.multipleTable.toggleRowSelection(this.saleMaterialList[index]);//index可以在for循环中获取

在这里插入代码片

如何清除所有的:

clearSelection:用于多选表格,清空用户的选择。

猜你喜欢

转载自blog.csdn.net/qq_42931285/article/details/124996367