My search filter currently filters results only by the ' packageName
' field. Now I need to filter by ' dateStart
' and ' dateFinish
' fields also.
getters: {
filteredPacks: (state, getters) => (search) => {
return state.packs.filter(pack => {
return pack.packageName.toLowerCase().indexOf(search) > -1
})
}
}
How do I filter results by multiple fields/criteria?
Here's an answer: https://stackoverflow.com/a/31831801/532675 . To be more specific:
getters: {
filteredPacks: (state, getters) => (term) => {
return state.packs.filter(pack => {
for(var key in term) {
if(pack[key] === undefined || pack[key] != term[key])
return false;
}
return true;
})
// or add more specific/straight 'if' checks
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.