I want to create a custom Vue component for a "radio div" -- a div (with a slot for including any content I want) that acts like a radio button so you can select it and only one can be selected among multiple with the same name.
In general radio buttons in VueJS look like so:
<input type="radio" name="name" value="value" v-model="variable" />
So I wanted a similar API:
<div-radio name="name" value="value" v-model="variable" />
However when I looked up how to add v-model support to custom component the first link I found on Google claimed:
For
inputelements, you might usev-modellike this:<input v-model="email" />
v-modeltranslates to this:<input :value="email" @input="e => email = e.target.value" />
If v-model translates to :value and @input then it doesn't seem possible to have a prop called "value" at the same time as "v-model" - despite the fact this is how normal VueJS radio buttons work
Am I misunderstanding how v-model works? Or is there an alternate solution? Or is what I want just not possible?