Skip to content

Commit 1fb40a3

Browse files
committed
fix: table pagination current error
1 parent 1add0d2 commit 1fb40a3

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

components/table/hooks/usePagination.ts

+16-14
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,22 @@ export default function usePagination(
6363
}));
6464

6565
// ============ Basic Pagination Config ============
66-
const mergedPagination = computed(() =>
67-
extendsObject<Partial<TablePaginationConfig>>(innerPagination.value, pagination.value, {
68-
total: paginationTotal.value > 0 ? paginationTotal.value : totalRef.value,
69-
}),
70-
);
71-
72-
// Reset `current` if data length or pageSize changed
73-
const maxPage = Math.ceil(
74-
(paginationTotal.value || totalRef.value) / mergedPagination.value.pageSize!,
75-
);
76-
if (mergedPagination.value.current! > maxPage) {
77-
// Prevent a maximum page count of 0
78-
mergedPagination.value.current = maxPage || 1;
79-
}
66+
const mergedPagination = computed(() => {
67+
const mP = extendsObject<Partial<TablePaginationConfig>>(
68+
innerPagination.value,
69+
pagination.value,
70+
{
71+
total: paginationTotal.value > 0 ? paginationTotal.value : totalRef.value,
72+
},
73+
);
74+
// Reset `current` if data length or pageSize changed
75+
const maxPage = Math.ceil((paginationTotal.value || totalRef.value) / mP.pageSize!);
76+
if (mP.current! > maxPage) {
77+
// Prevent a maximum page count of 0
78+
mP.current = maxPage || 1;
79+
}
80+
return mP;
81+
});
8082

8183
const refreshPagination = (current = 1, pageSize?: number) => {
8284
if (pagination.value === false) return;

0 commit comments

Comments
 (0)