Home > Software engineering >  Vue / Vuetify: Search and filter as I type rather than key enter
Vue / Vuetify: Search and filter as I type rather than key enter

Time:10-13

I currently have a search setup that when I press enter the search method is called. What I would like to do is rather than lookup the speech is retrieve all results and then filter down matching the search criteria. Any advice?

Search:

<v-text-field
  v-model="search"
  @keyup.enter="search"
/>

Data:

  data () {
    return {
      search: null,

Method:

search () {
  // search
},

CodePudding user response:

You could create a watcher for searchQuery which would trigger search() method each time it's changed.

watch: {
    searchQuery: function (value) {
        this.search()
    }
}
  • Related