0👍
✅
JSON doesn’t understand dates, so a good practice is to convert date strings to date objects when you deserialize. Then, you want to put your source data in a store, and create computed properties for your filtered arrays.
Here’s the code for the filtered property…
displayDates(){
var now = new Date(Date.now());
switch(vueStore.currView){
case 'all': return vueStore.allDates;
case 'month' : return vueStore.allDates.filter(
line => line.date > new Date(now.getFullYear(), now.getMonth(),0)
);
case 'year' : return vueStore.allDates.filter(
line => line.date > new Date(now.getFullYear(), 0,0)
)
}
}
Source:stackexchange.com