Skip to content

The current will be reassigned once in data(), taking the smallest of the current and page max values, should this trigger the onChange event? I think it should be triggered. #5589

@zhi-zhi-zhi

Description

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

Version

3.2.3

Environment

Vue: 3.2.3

Reproduction link

Edit on CodeSandbox

Steps to reproduce

just click the link

What is expected?

console will print 6 and then print 5
控制台打印 6,然后马上打印 5

What is actually happening?

just print 6
只打印 6


场景(Table):
0. 数据库共 31 条数据,table 每页 10 条,显示第 4 页

  1. 远程获取数据(current: 4, pageSize: 10),返回 (total: 31, data: [/一条数据/]),一条数据
  2. 页面上删除第 4 页第 1 条,删除后,数据库还剩 30 条
  3. 删除后重新获取数据(current:4, pageSize: 10) ,远程返回 (total: 30, data: []),注意注意注意,是 0 条数据
  4. pagination current prop 为 4,total 为 30,pageSize 为 10
  5. 在 pagination 对 total 的 watch 中,会将 stateCurrent 更新为 3(逻辑:Math.min(4, 3)) (4 props,3 为当前 total、pageSize 能显示的最大页码)
  6. 于是页面上,页码显示为 3,但显示的是第 4 页的空数据(因为 datasource 获取的是第 31-40 条的数据)
  7. 异常。第 3 页实际是能获取到第 21-30 条数据的

期望:

  1. total 的 watch 中,若 stateCurrent 改变,则触发 onUpdate:value 以及 onChange 事件
  2. 用户在 onChange 中根据新的页码 3,重新请求远程数据(第 21-30 条),页面页码显示 3,同时显示对应的数据

其他:
标题内只写了 data() ,实际上还包括 watch 中的 total()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions