I want to make a default value of the select option using vue.js
here is my code
<v-select
v-model="contact.title"
:options="['Mr','Mrs','Ms']">
</v-select>
and
export default {
props: {
contact: {
type: Object,
required: true,
},
titles: {
type: Array,
required: true,
},
},
};
thanks
Mutating a prop is not best practice in vue. You could do it like:
<v-select
v-model="selected"
:options="['Mr','Mrs','Ms']">
</v-select>
data: function () {
return {
selected: '' || 'defaultValue'
}
},
This way you are not mutating the prop and you easily can set a default value.
If you want to pass the data to the parent look at:
Pass data to parent