In my BlogList.vue
component I made a search input field:
<input type="text" placeholder="Enter key word ..." v-model="search">
And a computed property:
computed: {
getfilteredData() {
return this.blogs.filter(blog =>
blog.name.toLowerCase().includes(
this.search.toLowerCase()
) ||
blog.category.toLowerCase().includes(
this.search.toLowerCase()
)
)
}
},
The user can search on multiple values, i.e. blog.name
and blog.category
, which updates the list accordingly.
Can I write the above JavaScript (computed property) in a cleaner way?