How to work with vueJS search method?

Asked

Viewed 580 times

1

You realize the search is working perfectly:

https://jsfiddle.net/wladyband/8qor5c0x/

I wanted you to only list the records when you typed something in search input, 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 any idea how I could do that?

1 answer

2


Just you add one v-if in the loop to display the results. If your variable MySearch is with some value, the results will be displayed based on your search.

Look at line 34 of the code I made: https://jsfiddle.net/7xz8u8tL/1/

  • thanks a lot

Browser other questions tagged

You are not signed in. Login or sign up in order to post.