0👍
In your codepen the problem is that you are using the same array for parents and children, so both addParent and addChildren function edit the same array.
addParent: function () {
this.form.parent.push({
name: '',
age: '',
});
},
addChildren: function (index) {
console.log(index);
this.form.parent.splice([index], 0, {
child: {
name: '',
school: '',
}
});
},
I think that what you want is that for each item in parents array there is an array of children. Try out this pen and let me know if I correctly understand your problem
- [Vuejs]-How to full state before going throw script in component vue
- [Vuejs]-Why Vue data is not updating int his case
Source:stackexchange.com