If you are looking to capture user input in a v-autocomplete
component in Vuetify, you can utilize the @update:search-input
event. This event is triggered when the user types in the autocomplete field. By passing it a simple function like the one below, you can search for the input word within a list of items:
<v-autocomplete
v-model="values"
:items="items"
outlined
dense
chips
small-chips
label="Outlined"
multiple
@update:search-input="handleChange"
></v-autocomplete>
Here's an example of the handleChange
method:
methods: {
handleChange(searchWord) {
if (this.items.filter(value => value.startsWith(searchWord)).length === 0) {
// Handle case where no data matches the search term
console.log("No data available")
}
}
}
It appears that there isn't a straightforward way to access the filtered list directly in Vuetify, so you may need to implement your own filter function. For more examples and code snippets related to this functionality, check out this CodePen link.