I am building a radio button, which use a default image (black-radio.png or white-radio.png without checkmark) when the button is not checked, else they use black-radio-checked.png or white-radio-checked.png. But really stuck with this bug. I know there is an option to use computed property, but how should I solve this?
var vm = new Vue({
el: '#colorPicker',
data: {
color: 'black',
colors: [
{
name: 'black',
image: 'images/black-radio.png',
image_checked: 'images/black-radio-checked.png'
},
{
name: 'white',
image: 'images/white-radio.png',
image_checked: 'images/white-radio-checked.png'
}
]
}
});
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js" type="text/javascript"></script>
<div id="colorPicker">
<div class="display-inline-block">
<label :for="colorInfo.name" v-for="(colorInfo, index) in colors">
<input type="radio" name="color" v-model="color" :id="colorInfo.name" class="wireless-headphone-new-input" :value="colorInfo.name"/>
<img :src="'images/' + colorInfo.name + '-radio.png'">
</label>
<div class="confirmation-color capitalize">{{ color }} </div>
</div>
</div>
