el-table表格选中行和回显行

小知识(6) el-table表格选中行和回显行(vue3)-LMLPHP

环境:vue3+element-plus

选中行selection

<el-table ref="baseTableRef" row-key="id" border :selection="true" :reserve-selection="true" :data="dataList">
    <el-table-column type="selection" width="55"></el-table-column>
    <el-table-column label="名称" prop="name" align="center" />
</el-table>

回显选中行

function init(){
 nextTick(() => {
    let row = dataList[0]; // 行数据
    proxy.$refs.baseTableRef.toggleRowSelection(row, true);
  });
}

拿到当前选中的行数据列表

proxy.$refs.baseScopeTableRef.getSelectionRows()
10-26 09:21