N
Nuxt5mo ago
Jan

pass data from child component to parent

Hey, so I have in one I my pages a v-for on a component called <DataCreator/> inside of the data creator I have an input:text two selectors and a couple of checkboxes. How can I access the data of those inside of the page?
3 Replies
Omnislash
Omnislash5mo ago
Hello 🙂 I'm not fully sure to understand what you want to do, but you basically have two options : 1/ Emit event : https://vuejs.org/guide/components/events.html#emitting-and-listening-to-events 2/ v-model, which are "two-way props" : https://vuejs.org/guide/components/v-model.html Don't hesitate to give more details on what you do exactly and what result you except if the links aren't enough ^^
Patrity
Patrity5mo ago
What you'll want to do is emit the changes from the child component to the parent component. I typically use VueUse for this. I was going to post an example from my code, but the vue use docs give a great example: https://vueuse.org/core/useVModel/ in the example script setup block, you'd want to call the component from the parent like <SomeComponent v-model:modelValue="someValue" />
Jan
Jan5mo ago
Thanks, works great
Want results from more Discord servers?
Add your server