Commit e32789373eb5b1b531572b59692bf552dac365dc
1 parent
c375e323
fix(table): fix `pagination` props working
修复table的pagination属性无法动态设置数据的问题
Showing
2 changed files
with
12 additions
and
1 deletions
CHANGELOG.zh_CN.md
@@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
11 | - **BasicTable** | 11 | - **BasicTable** |
12 | - 修复全屏模式下看不到子组件弹出层(popconfirm 以及 select、treeSelect 等编辑组件)的问题 | 12 | - 修复全屏模式下看不到子组件弹出层(popconfirm 以及 select、treeSelect 等编辑组件)的问题 |
13 | - 修复启用`expandRowByClick`时,点击不可展开的行可能会导致样式错误的问题 | 13 | - 修复启用`expandRowByClick`时,点击不可展开的行可能会导致样式错误的问题 |
14 | + - 修复`pagination`属性动态改变不生效的问题 | ||
14 | - **Dark Theme** 黑暗主题下的配色问题修正 | 15 | - **Dark Theme** 黑暗主题下的配色问题修正 |
15 | - 修复`Tree`组件被选中节点的背景颜色 | 16 | - 修复`Tree`组件被选中节点的背景颜色 |
16 | - 修复`Alert`组件的颜色配置 | 17 | - 修复`Alert`组件的颜色配置 |
src/components/Table/src/hooks/usePagination.tsx
1 | import type { PaginationProps } from '../types/pagination'; | 1 | import type { PaginationProps } from '../types/pagination'; |
2 | import type { BasicTableProps } from '../types/table'; | 2 | import type { BasicTableProps } from '../types/table'; |
3 | -import { computed, unref, ref, ComputedRef } from 'vue'; | 3 | +import { computed, unref, ref, ComputedRef, watchEffect } from 'vue'; |
4 | import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue'; | 4 | import { LeftOutlined, RightOutlined } from '@ant-design/icons-vue'; |
5 | import { isBoolean } from '/@/utils/is'; | 5 | import { isBoolean } from '/@/utils/is'; |
6 | import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '../const'; | 6 | import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '../const'; |
@@ -27,6 +27,16 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) { | @@ -27,6 +27,16 @@ export function usePagination(refProps: ComputedRef<BasicTableProps>) { | ||
27 | const configRef = ref<PaginationProps>({}); | 27 | const configRef = ref<PaginationProps>({}); |
28 | const show = ref(true); | 28 | const show = ref(true); |
29 | 29 | ||
30 | + watchEffect(() => { | ||
31 | + const { pagination } = unref(refProps); | ||
32 | + if (!isBoolean(pagination) && pagination) { | ||
33 | + configRef.value = { | ||
34 | + ...unref(configRef), | ||
35 | + ...(pagination ?? {}), | ||
36 | + }; | ||
37 | + } | ||
38 | + }); | ||
39 | + | ||
30 | const getPaginationInfo = computed((): PaginationProps | boolean => { | 40 | const getPaginationInfo = computed((): PaginationProps | boolean => { |
31 | const { pagination } = unref(refProps); | 41 | const { pagination } = unref(refProps); |
32 | 42 |