diff --git a/src/components/accordion/VAccordion.vue b/src/components/accordion/VAccordion.vue index c130e49..1eca4ce 100644 --- a/src/components/accordion/VAccordion.vue +++ b/src/components/accordion/VAccordion.vue @@ -8,17 +8,22 @@ const props = withDefaults(defineProps(), { value: null, }); +// Define the event emitter for v-model binding const emit = defineEmits([ 'update:value', ]) +// Local reactive value to sync with the parent v-model const localValue = ref(props.value); + +// Watch for external changes to the prop and update localValue accordingly watch(() => props.value, (newVal) => { if(localValue.value !== newVal) { localValue.value = newVal; } }); +// Watch for internal changes to localValue and emit them to the parent watch(localValue, (newVal) => { if(props.value !== newVal){ emit('update:value', newVal);