How to work with search method in VueJS?

1

You realize that the search is working perfectly:

link

I wanted to only list the records when something was typed in the input search , I know what place to make this change would be in that code snippet:

 filteredBancodedaos () {
          return this.bancodedados
          .filter((bancoDeDado)=>{
              return ( 
                bancoDeDado.name.match(this.MySearch) ||
                bancoDeDado.height.match(this.MySearch) ||
                bancoDeDado.mass.match(this.MySearch) ||
                bancoDeDado.eye_color.match(this.MySearch) ||
                bancoDeDado.gender.match(this.MySearch) ||
                bancoDeDado.hair_color.match(this.MySearch)
              )

        })
      }
    }

Would anyone have an idea how I could do this?

    
asked by anonymous 13.02.2018 / 17:18

1 answer

2

Just add a v-if to the loop to show the results. If your MySearch variable has a value, the results will be displayed based on your search.

See line 34 of the code I made: link

    
13.02.2018 / 17:34