I am trying to change the filter by changing the filterKey on a click event, is this possible? Or is there a better way to achieve this?
<a href="#" v-on:click="filterKey = 'all'">All</a>
<a href="#" v-on:click="filterKey = 'nearby'">Nearby</a>
<ul v-for="user in users | filterBy filterKey">
<li>{{user.name}}</li>
</ul>
data () {
return {
filterKey: 'all',
users: users,
}
},
filters: {
all: (users) => {
return users
},
nearby: (users) => {
return users.filter((users) => {
return users.distance <= 15
})
}
}