Skip to content

Commit 18cc95f

Browse files
committed
fix: table warning for page, close #5029
1 parent 66eb020 commit 18cc95f

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

components/table/Table.tsx

+20-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import defaultLocale from '../locale/en_US';
3535
import type { SizeType } from '../config-provider';
3636
import devWarning from '../vc-util/devWarning';
3737
import type { PropType } from 'vue';
38-
import { reactive, ref, computed, defineComponent, toRef, watchEffect, watch } from 'vue';
38+
import { nextTick, reactive, ref, computed, defineComponent, toRef, watchEffect, watch } from 'vue';
3939
import type { DefaultRecordType } from '../vc-table/interface';
4040
import useBreakpoint from '../_util/hooks/useBreakpoint';
4141
import useConfigInject from '../_util/hooks/useConfigInject';
@@ -465,11 +465,6 @@ const InteralTable = defineComponent<
465465
// Dynamic table data
466466
if (mergedData.value.length < total!) {
467467
if (mergedData.value.length > pageSize) {
468-
devWarning(
469-
false,
470-
'Table',
471-
'`dataSource` length is less than `pagination.total` but large than `pagination.pageSize`. Please make sure your config correct data with async mode.',
472-
);
473468
return mergedData.value.slice((current - 1) * pageSize, current * pageSize);
474469
}
475470
return mergedData.value;
@@ -478,6 +473,25 @@ const InteralTable = defineComponent<
478473
return mergedData.value.slice((current - 1) * pageSize, current * pageSize);
479474
});
480475

476+
watchEffect(
477+
() => {
478+
nextTick(() => {
479+
const { total, pageSize = DEFAULT_PAGE_SIZE } = mergedPagination.value;
480+
// Dynamic table data
481+
if (mergedData.value.length < total!) {
482+
if (mergedData.value.length > pageSize) {
483+
devWarning(
484+
false,
485+
'Table',
486+
'`dataSource` length is less than `pagination.total` but large than `pagination.pageSize`. Please make sure your config correct data with async mode.',
487+
);
488+
}
489+
}
490+
});
491+
},
492+
{ flush: 'post' },
493+
);
494+
481495
const expandIconColumnIndex = computed(() => {
482496
// Adjust expand icon index, no overwrite expandIconColumnIndex if set.
483497
if (expandType.value === 'nest' && props.expandIconColumnIndex === undefined) {

0 commit comments

Comments
 (0)