0👍
Define a computed property that filters your projects
returning just the objects that have a true
value for the favorite
property.
I’m making some assumptions regarding the structure of your project
object, however, the principle will remain the same.
An example of how you could filter results below:
let projects = [
{
id: 1,
favorite: true
},
{
id: 2,
favorite: false
},
{
id: 3,
favorite: false
},
{
id: 4,
favorite: true
}
];
let filteredProjects = projects.filter(p => p.favorite);
Obviously, you’re not using a static array as I have in the example so you will need to alter it for your use case (e.g. state.projects.filter(p => p.favorite)
). You could also use lodash filter if you’re already using that library.
- [Vuejs]-Custom styling of tags using the elements-plus select multiple packs in Vue 3
- [Vuejs]-How can I translate the option in SELECT using i18N in VUE3
Source:stackexchange.com