0
点赞
收藏
分享

微信扫一扫

刷新视图但不刷新选中状态/分页记住选中状态

是她丫 2022-02-15 阅读 32
<!-- reserve-selection:仅对 type=selection 的列有效,类型为 Boolean,为 true 则会在数据更新之后保留之前选中的数据(需指定 row-key) -->
<table ref="tableRef" @selection-change="checkClick" :row-key="rowKey">
    <table-column type="selection" :reserve-selection="true"></table-column>
</table>
checkClick(selection) {
    this.selection = selection;
}

rowKey(row) {
    return row.cartId;
}

watch: {
    // val:表格数据源
    goodList(val) {
        val.forEach(item => {
            // 表中选中的数据列表
            vue.selection.forEach(self => {
                if(self.cartId === self.cartId) {
                    // 更新当前行的选中状态
                    vue.$refs.tableRef.toggleRowSelection(item, true);
                }
            })
        })
    }
}
举报

相关推荐

0 条评论