Does this work?
<input name="myfield" type="radio" v-bind:checked="{ item.val == comparisonvalue }">
Untested
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a component and I need to loop through an array of values to create a radio list (v-for is perfect) and to check only a specific radio (by matching its value with another component data value). Need this operation to be performed on load.
comparisonvalue = 2
items =
[
{txt: 'foo', val: 1},
{txt: 'bar', val: 2}
]
<div v-for="item in items">
<input name="myfield" type="radio" v-bind:value="item.val" v-bind:checked="item.val==comparisonvalue">
<label>{{ item.txt }}</label>
</div>
it doesn't work correctly ...
Please or to participate in this conversation.