1👍
selected
attribute no longer makes sense when you using v-model
.
- [Vuejs]-What's the point of hardcoded class properties in Vue Options API/
- [Vuejs]-Find div on scroll using VUE.js
0👍
You can’t use selected
attribute if you are using v-model
on the <select>
, Set the v-model
value to the default value instead:
<template>
<div id="app">
<select id="plans" class="form-control" v-model="company.plan_id">
<option v-for="plan in plans" :value="plan.id" :key="plan.id" :selected="plan.default">{{plan.name}}</option>
</select>
</div>
</template>
<script>
export default {
name: "App",
data() {
return {
company: {
plan_id: 18
},
plans: [
{ id: 20, name: "test" },
{ id: 19, name: "haha" },
{ id: 18, name: "okok" }
]
};
}
};
</script>
Demo here: https://codesandbox.io/s/beautiful-sound-gxmzu?file=/src/App.vue
- [Vuejs]-Tooltip for bootstrap-sass is not work
- [Vuejs]-Vue : Store dynamic number of inputs in an dynamic two dimensional array
Source:stackexchange.com