I currently have a parent component that has 2 children.
Both the children are simple <input>
fields
In my parent, I have a button (this a form afterall), when click, I'd like to get the values of both children in my parent, so I can send it to an API endpoint.
Whats the easiest way?
I've seen props
and $emit
but not sure which is the best approach
Thanks
EDIT:
My parent looks like following:
<template>
<div>
<name-filter></name-filter>
<report-type-filter></report-type-filter>
<button @click="sumbmitForm()">Submit</button>
</div>
</template>
<script>
import NameFilter from './filters/NameFilter.vue';
import ReportTypeFilter from './filters/ReportTypeFilter.vue';
export default{
components: {
NameFilter,
ReportTypeFilter
},
data() {
return {
name: "",
type: ""
};
},
methods: {
sumbmitForm() {
// I'd like to get the <input> values here
}
}
}
</script>