0👍
It’s difficult to understand what you’re trying to do and what the problem is because the question looks like a mess, but I’ll try to help anyway.
Demo:
Here’s a working example with your data:
https://codepen.io/AlekseiHoffman/pen/XWJmpod?editors=1010
Template:
<div id="app">
<div v-for="(selection, index) in choice.selections">
<input
type="radio"
:id="selection.id"
:value="selection.selectionId"
v-model="choice.selected"
>
<label>
{{selection.description}}
</label>
</div>
<div>
Selected: {{ choice.selected }}
</div>
</div>
Script:
choice: {
"id": 1,
"selected": 2,
"selections": [
{
"selectionId": 1,
"description": "Radio One"
},
{
"selectionId": 2,
"description": "Radio Two"
}
]
}
I simplified the JSON object since the other properties are not needed there to make it work.
Let me know if you’re still having difficulties with your task.
- [Vuejs]-Vuex getters used in a component show errors in console because at the time of their calling, the Vuex state properties are still null
- [Vuejs]-Passing the Properties of an Object to method in Vue.Js
Source:stackexchange.com