'Get values from enum field to dynamic populate radio buttons in Vue
I'm making todo vue component. One of the fields (MySQL table todos) is enum type: priority enum('high', 'medium', 'low'). How can I make radio buttons from that field or should I use some other field type?
I added manually data property with enum field values:
data() {
return {
priorities: [{ name: 'High' }, { name: 'Medium' } , { name: 'Low' }],
}
},
Then in template dynamically created radio buttons:
<label >Priority</label>
<div v-for="(priority, index) in priorities" :key="index">
<input type="radio" :name="priority.name" :value="priority.name" v-model="form.priority" :id="priority.name">
<label :for="priority.name">{{ priority.name }}</label>
</div>
I want to get default values from enum field.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
