[Vuejs]-Filter elements of an array and display them using the same array

0👍

You can manage a filterBy state in your pinia store which will track the type of filter that have been applied. Then, you can have a computed value with getters like this:

getters: {
    filteredArray: (state) => state.filterBy ? state.array.filter((val) => val.type === state.filterBy) : state.array;
}

Leave a comment