✨ feature: emit handler added
This commit is contained in:
parent
34427c40a2
commit
4ddb99a878
|
@ -2,14 +2,37 @@
|
||||||
import Accordion from 'primevue/accordion';
|
import Accordion from 'primevue/accordion';
|
||||||
import VAccordionChild from './VAccordionChild.vue';
|
import VAccordionChild from './VAccordionChild.vue';
|
||||||
import type IVAccordion from './IVAccordion.type';
|
import type IVAccordion from './IVAccordion.type';
|
||||||
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<IVAccordion>(), {
|
const props = withDefaults(defineProps<IVAccordion>(), {
|
||||||
value: null,
|
value: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits([
|
||||||
|
'update:value',
|
||||||
|
])
|
||||||
|
|
||||||
|
const localValue = ref(props.value);
|
||||||
|
watch(() => props.value, (newVal) => {
|
||||||
|
if(localValue.value !== newVal) {
|
||||||
|
localValue.value = newVal;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(localValue, (newVal) => {
|
||||||
|
if(props.value !== newVal){
|
||||||
|
emit('update:value', newVal);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Accordion :value="props.value" class="p-accordion" style="width: 100%;">
|
<Accordion
|
||||||
|
v-model:value="localValue"
|
||||||
|
class="p-accordion"
|
||||||
|
style="width: 100%;"
|
||||||
|
@update:value="emit('update:value', $event)"
|
||||||
|
>
|
||||||
<slot>
|
<slot>
|
||||||
<VAccordionChild/>
|
<VAccordionChild/>
|
||||||
</slot>
|
</slot>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user