完整版:https://my.oschina.net/u/3774949/blog/3102604

需求又变了,说是让选中也可以进行实时刷新,又网上找了下,发现大佬写法:https://juejin.im/post/5cce4d5af265da0374188d23

其实element ui 官网就有写法,还是要多看看文档-0.0-

官网是说当数据实时更新时也能选中element ui  的  checkbox-LMLPHP

代码为

<!-- stripe--启用马纹线   border--启用边框  highlight-current-row--启用单选 sortable--启用排序-->
<el-table ref="multipleTable" :data="tables.slice((currentPage-1)*pagesize,currentPage*pagesize)"
          stripe border highlight-current-row tooltip-effect="dark"
          style="width: 100%;font-size: 13px"
          :cell-style="{padding:'0px'}"
          @row-click="rowClick"
          :row-style="rowStyle"
          :row-class-name="rowClassName"
          @selection-change="handleSelectionChange"
          :row-key="getRowKeys">
    <el-table-column sortable :reserve-selection="true" type="selection" width="55"></el-table-column>
    <el-table-column sortable prop="test" label="test" show-overflow-tooltip></el-table-column>
    <el-table-column sortable prop="test" label="test" show-overflow-tooltip></el-table-column>
    <el-table-column sortable prop="test" label="test" show-overflow-tooltip></el-table-column>
    <el-table-column sortable prop="test" label="testtest" show-overflow-tooltip></el-table-column>
    <el-table-column sortable prop="test" label="test" show-overflow-tooltip></el-table-column>
</el-table>

需要加入代码已加粗加下划线 这个不能直接reserve-selection="true"这样写

会报错Invalid prop: type check failed for prop "reserveSelection". Expected Boolean, got String with value "true".

错误大致为需要一个boolean类型的参数,但是传入为String类型的需要加上   :reserve-selection="true"

还有要返回一个当前行标识

// 指定返回的行
getRowKeys(row){
    return row.id;
},
10-14 16:00