修改前代码
<el-table
class="margin-top-10"
:data="tableList"
style="width: 99%;"
size="mini"
:header-cell-style="getTableHeaderRowClass"
stripe
tooltip-effect="light"
>
<el-table-column
prop="support_cpd"
label="开启投放CPD权限"
align="center"
width="150"
>
<template slot-scope="scope">
<el-checkbox
@change="supportCpd(scope.row)"
:checked="scope.row.support_cpd===1 ? true : false">
</el-checkbox>
</template>
</el-table-column>
<el-table>
设置了第二页该项勾选了, 再到第一页,再到第二页, 该项没被勾选
解决方案:
需要在el-table 中增加:row-key="(row)=>{return row.id}"
在el-table-column 中增加 :reserve-selection="true"
修改后的代码:
<el-table
class="margin-top-10"
:data="tableList"
style="width: 99%;"
size="mini"
:header-cell-style="getTableHeaderRowClass"
stripe
tooltip-effect="light"
:row-key="(row)=>{return row.id}" //***************
>
<el-table-column
prop="support_cpd"
label="开启投放CPD权限"
align="center"
width="150"
:reserve-selection="true" //***************
>
<template slot-scope="scope">
<el-checkbox
@change="supportCpd(scope.row)"
:checked="scope.row.support_cpd===1 ? true : false">
</el-checkbox>
</template>
</el-table-column>
<el-table>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。