Vue selected prop not working with v-model
Another solution is by using $refs
instead of v-model.
<select ref="selectedItem">
<option v-for="(item, index) in items" :value="item.id" :selected="item.status == 2">
{{ item.name }}
</option>
</select>
Then to get the value of the selected item, call...
this.$refs.selectedItem.value
v-model will ignore the initial value, checked or selected attributes. found on any form elements
The solution is to remove :selected binding. and use data props to bind to v-model
<select v-model="form.selectedItem">
<option :value="item.id" v-for="(item, index) in items">{{ item.name }}
</option>
</select>
declare vue instance as
data() {
return {
selectedItem: 2
}
}
link to official documentation