[Vuejs]-Multiple fields search form without duplicating the component for each search condition

0👍

I suppose you should rename filteredResults function into getFilteredResults, add filteredResults as an array to a data section and in search function do somethng like this:

<result-item
  :data="filteredResults"
  :total-pages="Math.ceil(filteredResults.length / 10)"
  :total="filteredResults.length"
  :per-page="10"
  :current-page="currentPage"
  @pagechanged="onPageChange"
/>
...
methods: {
  search () {
    this.filteredResults = this.getFilteredResults()
  }
  reset () {
   // clear all fields here
   ...
   this.filteredResults = []
  }
}

Leave a comment