I can't quite recall the answer to this at the moment.
Consider an array of Vendors (this is just placeholder data):
[
{
"user_updated": null,
"user_created": "128a84b5-275c-4f00-942e-e8ba6d85c60e",
"date_created": "2021-03-13T23:41:09Z",
"date_updated": null,
"website": "www.example.com",
"payment_information": "IBAN: THEIR1234IBAN567",
"tax_id": null,
"vat_id": "1234567890",
"services": "Produzione video, animazioni",
"name": "Video Productions Ltd.",
"address": "Viale Lorenteggio, 20\nMilano 20142",
"notes": "Competenze di alto livello",
"id": 1,
"inactive": false
}
]
I am trying to filter by name
, services
, and website
using:
data() {
return {
filter: ''
}
},
computed: {
filteredVendors() {
return this.vendors.filter(({name, notes, services, website}) => {
const filter = this.filter.toLowerCase()
return (
name.toLowerCase().includes(filter) || notes.toLowerCase().includes(filter)... // continue for other fields
)
})
}
}
However, I'm having trouble filtering based on the boolean field (inactive
). How can I filter for either inactive=false or inactive=true?
UPDATE: I managed to solve it with this method, but I'm unsure if it's efficient. https://i.sstatic.net/ffEGg.png
Thank you!