Level 47
It's not working because you are returning in each if check. I'd recommend using the ids instead of the names in the checkedFilters to make it easier to filter. I think something like this should work:
data () {
return {
positions: [],
filters: [
{ name: 'SE', id: 1 },
{ name: 'US', id: 2 }
],
checkedFilters: [1, 2]
};
},
computed: {
filteredPositions () {
return this.positions.filter(position => this.checkedFilters.includes(position.country_id));
}
}
1 like