We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 793b16e commit f4eeb2eCopy full SHA for f4eeb2e
src/hooks/common/table.ts
@@ -40,17 +40,20 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
40
transformer: res => {
41
const { records = [], current = 1, size = 10, total = 0 } = res.data || {};
42
43
+ // Ensure that the size is greater than 0, If it is less than 0, it will cause paging calculation errors.
44
+ const pageSize = size <= 0 ? 10 : size;
45
+
46
const recordsWithIndex = records.map((item, index) => {
47
return {
48
...item,
- index: (current - 1) * size + index + 1
49
+ index: (current - 1) * pageSize + index + 1
50
};
51
});
52
53
54
data: recordsWithIndex,
55
pageNum: current,
- pageSize: size,
56
+ pageSize,
57
total
58
59
},
0 commit comments