I am using Vue 2 and I'm trying to have a parent component pass in multiple values to the child, and have the child return back a specific object to the parent. It needs to be two way data binding for the data.
For example I have this school object:
school: {
name: "Tech School",
type: "highschool"
}
A list of students with different properties: (The list can be huge, but this is pseudo code)
data () {
return {
totalStudents: [{
school: {
name: "Tech School",
type: "highschool"
},
studentId: 123,
city: "seattle"
},
school: {
name: "Art School",
type: "university"
}
studentId: 747,
city: "toronto"
},
}],
}
}
The parent calls this custom child component (I'm not sure how to write this part)
<CustomChildPicker :value="prop" @input="prop=
totalStudents[index].school, // trying to pass these 3 fields from parent to child
totalStudents[index].studentId,
totalStudents[index].city"
v-model=totalStudents[index].school //only want this updated data back from child
/>
How do we pass in dynamic data to the child component, but only have the school object have two way data binding with the parent?
I want to pass data from the parent to the child, and the child does some conversions to that data and pass the converted data back to the parent. (school object)
But also if the data in the parent changes, the child gets the updated changed data, redo the conversions above and give the updated data back to the parent. (if the student's city changes, then their school also changes)
How would we do this? Thanks for the help!