When using VueX, I am attempting to filter my "ListJobs" array based on the currentTag. Essentially, I want to return elements that match any of the values in the currentTag array with the rows role, level, languages, and tools.
state: [
listJobs: [
{
"id": 1,
"company": "Photosnap",
"role": "Frontend",
"level": "Senior",
"languages": ["HTML", "CSS", "JavaScript"],
},
{
"id": 2,
"company": "Manage",
"role": "Frontend",
"level": "Senior",
"languages": ["HTML", "CSS", "JavaScript"],
},
{
"id": 3,
"company": "Account",
"role": "Frontend",
"level": "Senior",
"languages": ["HTML", "CSS", "JavaScript"],
},
],
currentTag: [],
I attempted a solution like this, which currently only works for the Role line. My goal is for it to work for all fields.
getters: {
getJobs(state) {
if (state.currentTag.length > 0) {
return state.listJobs.filter(job => job['role'].includes(state.currentTag))
} else {
return state.listJobs
}
}
},