Skip to content

Commit 1589776

Browse files
committed
fix: collapse flash on init
1 parent 3d5aa61 commit 1589776

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/components/collapse/Collapse.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script>
22
import { addClass, removeClass } from '../../utils/dom.utils';
3-
import { onMounted, ref, watchEffect, defineComponent, h } from 'vue';
3+
import { onMounted, ref, defineComponent, h, watch } from 'vue';
44
55
export default defineComponent({
66
props: {
@@ -59,7 +59,18 @@ export default defineComponent({
5959
}
6060
}
6161
62-
watchEffect(toggle);
62+
watch(
63+
() => props.modelValue,
64+
() => {
65+
toggle();
66+
}
67+
);
68+
69+
onMounted(() => {
70+
if (props.modelValue) {
71+
addClass(element.value, IN);
72+
}
73+
});
6374
6475
return () =>
6576
h(props.tag, { ref: element, class: COLLAPSE }, slots.default?.());

0 commit comments

Comments
 (0)