Skip to content

分页组件在当前页仅 1 条数据被删除后,current 值未正确更新(未自动跳转前一页) #8408

@Caoyn1110

Description

@Caoyn1110
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

undefined

Environment

vue: "3.4.27", ant-design-vue: "4.2.5", Google Chrome142.0.7444.61, win11

Reproduction link

https://antdv.com/components/pagination

Steps to reproduce

使用 a-pagination 组件时,遇到一个数据同步问题:当当前页仅有 1 条数据,删除该数据后,分页组件的显示状态与 current 绑定值未同步。
复现场景:
初始条件:pageSize=10,total=11,current=2(即第 2 页仅有 1 条数据)。
操作:删除第 2 页的这条数据,此时 total 变为 10(总数据量为 10,刚好 1 页)。
预期:分页组件应自动跳转至第 1 页,且 current 绑定值同步更新为 1。
实际结果:分页组件 UI 显示为第 1 页,但 current 绑定值仍为 2(未双向绑定更新),导致数据与分页状态不一致。

What is expected?

当 当前页仅有 1 条数据,删除该数据导致总数据量减少后:
分页组件的 current 绑定值应自动更新为合理的页码(例如:原当前页为 2,删除后总数据量刚好够 1 页时,current 应变为 1);
分页组件的 UI 显示与 current 绑定值保持一致(即 UI 显示第 1 页,current 值也为 1);
双向绑定生效,外部可通过 current 值获取到最新的当前页状态。

What is actually happening?

当 当前页仅有 1 条数据,删除该数据导致总数据量减少后:
分页组件的 UI 显示会自动切换到前一页(例如:原当前页为 2,删除后 UI 显示第 1 页);
但 v-model:current 绑定的 current 变量值未更新(仍为删除前的 2);
双向绑定失效,外部获取到的 current 值与组件 UI 显示不一致,导致依赖 current 的数据加载等逻辑出错。


删除操作会更新 total 的值,但当 total 减少到 “当前页页码 ×pageSize” 以下时(如当前页 2,pageSize=10,total 变为 10),组件 UI 会切换到第 1 页,但 current 变量的值未自动更新为 1,导致双向绑定失效,数据加载逻辑可能仍基于旧的 current 值执行,引发错误。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions