el-table, selection multi-selection gets the data through the interface and then displays it in reverse

First, add the ref attribute to el-table, and also add a row-key to el-table. The return value changes according to the value of your data binding, as follows:

  <el-table
    :data="list"
    ref="multipleTableRef"
    @selection-change="handleSelectionChange"
    :row-key="
      (row) => {
    
    
        return row.id;
      }
    "
  >
  ....
  </el-table>

Then write it in the script as follows:


const getAssign = (value) => {
    
    
  multipleSelection.value = value;
  multipleSelection.value.map((row) => {
    
    
      if(row.ischecked==='1'){
    
    
      //此条语句是对每一行添加选择的,如果要清空选择,可以使用multipleTableRef.value.clearSelection()方法
        multipleTableRef.value.toggleRowSelection(row, true);
      }
    });
};

This completes the reverse display.

Guess you like

Origin blog.csdn.net/weixin_45807026/article/details/126806778