I am working with an input type text in my vue js application.
This is the initial code snippet:
<input type="text" v-model="answer[index]" >
Here is the updated code:
<table>
<tr v-for="(question_overall, index) in questions">
<td>
{{ question_overall.question }}
<div>
<input type="text" :value="{id: question_overall.id , answer: ??}" v-model="answer[index]" >
</div>
{{ answer[index] }}
</td>
</tr>
</table>
data: function () {
return {
questions: [],
answer:{
id: null,
answer: null,
},
}
},
I am trying to echo out the v-model like this:
{{ answer[index] }}
The desired output should be:
{ "id": 1, "answer": "the value of this answer is from what I type in" }
Can someone help me solve this issue? Thank you!