[Vuejs]-Combine two computed properties into one

0๐Ÿ‘

โœ…

Try this:

  searchFilter() {
      return this.filteredTableData.filter (item => {
        return 
          item.name.toLowerCase().match(this.search.toLowerCase()) ||     
          item.level.toLowerCase().match(this.search.toLowerCase()) ||      
          item.house.toLowerCase().match(this.search.toLowerCase())
      });  
  },

Filter the filteredTableData as searchFilter, then use it in the template.

<tbody>       
    <tr v-for="(item, index) in searchFilter">  
        <td>{{ item.name }}</td>  
        <td>{{ item.level }}</td>  
        <td>{{ item.house }}</td>  
    </tr>
</tbody>

0๐Ÿ‘

You would not combine them. Your filter function should just consider both properties and it will trigger on either changing. So in essence your computed filter is the combined property.

Leave a comment