I'm using vue2 and laravel 6, and i'm trying to add input field into my table where the data:activities had a relationship with scores
<button type="button" @click="addAct" >add activity</button>
<tr v-for="(student,index) in students" :key="index">
<td v-for="(quiz,i) in activities" :key="i">
//When I used this i can display my data coming from DB. but i get an error
<input v-model="quiz.scores[index].scores"autocomplete="off" />
//When i used this input i can add dynamically but i can't display my DB data
<input v-model="quiz.scores[index]" autocomplete="off" />
</td>
</tr>
data() {
return {
activities:[{"id":42,"activity_title":"1","hps":"1",
"scores":[
{"id":158,"scores":2,"student_id":1,"activity_id":42},
{"id":159,"scores":2,"student_id":2,"activity_id":42},
{"id":160,"scores":2,"student_id":3,"activity_id":42},
{"id":161,"scores":2,"student_id":4,"activity_id":42}]
}],
students:[
{"name":"Ellis Corkery MD","id":1},
{"name":"Lucie Rau""id":2},
{"name":"Delia Donnelly","id":3},
{"name":"Chyna Barton","id":4}]
}
},
methods:{
addAct: function() {
this.activities.push( { activity_title: [], hps:[], scores:[] );
},
}
[Vue warn]: Error in render: "TypeError: quiz.scores[_vm.index] is undefined". I get this when i try using the first input into my template
index, maybe you meanti?indexis props and i'm displaying a relationship into my input where thescores:[]have many values @ Robert Rochaquizis defined, you are linking quiz to a model?