Commit 28078d4263b40baaf34ea9b155eb6f448392f25d

Authored by zuihou
1 parent 5fc28f92

refactor: 支持外部调用展开关闭接口

src/components/Container/src/collapse/CollapseContainer.vue
... ... @@ -24,7 +24,8 @@
24 24 </template>
25 25 <script lang="ts" setup>
26 26 import type { PropType } from 'vue';
27   - import { ref } from 'vue';
  27 + import { ref, defineExpose } from 'vue';
  28 + import { isNil } from 'lodash-es';
28 29 // component
29 30 import { Skeleton } from 'ant-design-vue';
30 31 import { CollapseTransition } from '/@/components/Transition';
... ... @@ -66,13 +67,17 @@
66 67 /**
67 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 72 if (props.triggerWindowResize) {
72 73 // 200 milliseconds here is because the expansion has animation,
73 74 useTimeoutFn(triggerWindowResize, 200);
74 75 }
75 76 }
  77 +
  78 + defineExpose({
  79 + handleExpand,
  80 + });
76 81 </script>
77 82 <style lang="less">
78 83 @prefix-cls: ~'@{namespace}-collapse-container';
... ...