vue.jsfiltersearchbar.when

I am looking for the command in a program that filters only when 3 letters are entered


I am looking for the command in a program that filters only when 3 letters are entered. Does anyone know what command or code I need to look for to find this?

Maybe it's also a Vue-Command, because my program is written in Vue.js.

Thank you


Solution

  • Pass the search input to a function first then validate the input. If passes the validation, proceed with searching.

    Assuming this is your search input

    <input v-model="searchInput"/>
    

    Add an input event handler

    <input v-model="searchFor" @input="searchHandler"/>
    

    Then validate the search input with searchHandler method

    new Vue({
    
      methods: {
        searchHandler (text) {
          if(text.length > 2){
          // Write your code on here
          }
        }
      }
    

    })