Commit 28078d4263b40baaf34ea9b155eb6f448392f25d
1 parent
5fc28f92
refactor: 支持外部调用展开关闭接口
Showing
1 changed file
with
8 additions
and
3 deletions
src/components/Container/src/collapse/CollapseContainer.vue
@@ -24,7 +24,8 @@ | @@ -24,7 +24,8 @@ | ||
24 | </template> | 24 | </template> |
25 | <script lang="ts" setup> | 25 | <script lang="ts" setup> |
26 | import type { PropType } from 'vue'; | 26 | import type { PropType } from 'vue'; |
27 | - import { ref } from 'vue'; | 27 | + import { ref, defineExpose } from 'vue'; |
28 | + import { isNil } from 'lodash-es'; | ||
28 | // component | 29 | // component |
29 | import { Skeleton } from 'ant-design-vue'; | 30 | import { Skeleton } from 'ant-design-vue'; |
30 | import { CollapseTransition } from '/@/components/Transition'; | 31 | import { CollapseTransition } from '/@/components/Transition'; |
@@ -66,13 +67,17 @@ | @@ -66,13 +67,17 @@ | ||
66 | /** | 67 | /** |
67 | * @description: Handling development events | 68 | * @description: Handling development events |
68 | */ | 69 | */ |
69 | - function handleExpand() { | ||
70 | - show.value = !show.value; | 70 | + function handleExpand(val: boolean) { |
71 | + show.value = isNil(val) ? !show.value : val; | ||
71 | if (props.triggerWindowResize) { | 72 | if (props.triggerWindowResize) { |
72 | // 200 milliseconds here is because the expansion has animation, | 73 | // 200 milliseconds here is because the expansion has animation, |
73 | useTimeoutFn(triggerWindowResize, 200); | 74 | useTimeoutFn(triggerWindowResize, 200); |
74 | } | 75 | } |
75 | } | 76 | } |
77 | + | ||
78 | + defineExpose({ | ||
79 | + handleExpand, | ||
80 | + }); | ||
76 | </script> | 81 | </script> |
77 | <style lang="less"> | 82 | <style lang="less"> |
78 | @prefix-cls: ~'@{namespace}-collapse-container'; | 83 | @prefix-cls: ~'@{namespace}-collapse-container'; |