I am seeking to develop a unique Vue component that functions as a "radio div" - essentially, a div with the ability to act like a radio button where only one among multiple can be selected at a time. The div will also have a slot for including any desired content.
Typically, radio buttons in VueJS are structured as follows:
<input type="radio" name="name" value="value" v-model="variable" />
Based on this structure, I envisioned an API like this:
<div-radio name="name" value="value" v-model="variable" />
However, upon researching how to add v-model support to custom component, the first Google search result I came across suggested:
When using
input
elements, you can implementv-model
in this manner:<input v-model="email" />
The translation of
v-model
is explained as:<input :value="email" @input="e => email = e.target.value" />
If v-model
translates to :value
and @input
, it seems challenging to incorporate a prop named "value" alongside "v-model" simultaneously - despite the conventional functioning of VueJS radio buttons.
Could it be that I am misunderstanding the functionality of v-model
? Are there alternative solutions available? Or is my desired outcome simply unattainable?