需求1:table组件的checkbox进行数据重显,默认显示已选中数据

// html
<Table ref="multipleTable" :data="dataArr" >
         <el-table-column type="selection" align="center"></el-table-column>
</Table>

// js

// table数据
let dataArr = [{name:'张三',id:1},{name:'李四',id:2}];

// 已选数据ID数组
let IDArr = [2];

// 复选
reselectFun(dataArr, IDArr ){
    this.$nextTick(function() {
        dataArr.forEach(row => {
            if (IDArr.includes(row.id)) {
                this.$refs.multipleTable.toggleRowSelection(row, true);
            }
        });
    });
}        

需求2:获取所有的选中数据

// 保存按钮
save(){
    // this.$refs.multipleTable.selection 获取所有选中的数据

    console.log(this.$refs.multipleTable.selection)
}

 

相关文章:

  • 2022-02-18
  • 2022-12-23
  • 2022-01-06
  • 2022-01-17
  • 2021-12-22
  • 2022-12-23
  • 2021-04-18
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案