In the code below I am using a v-autocomplete component
and a variable select
where the selected value is stored.
The watch
logs the value and type of select
.
The problem I'm facing is that when the text typed in the v-autocomplete is cleared, select
defaults to null instead of an empty string.
Is there any way to revert select
to an empty string instead of a null object?
<div id="app">
<v-app id="inspire">
<v-card>
<v-container fluid>
<v-row
align="center"
>
<v-col cols="12">
<v-autocomplete
v-model="select"
:items="items"
dense
filled
label="Filled"
clearable
></v-autocomplete>
</v-col>
</v-row>
</v-container>
</v-card>
</v-app>
</div>
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
items: ['foo', 'bar', 'fizz', 'buzz'],
select: "",
}),
watch:{
value:function(value){
console.log(this.select) // select value
console.log(typeof(this.value)); // select variable type
}
}
})