The events By Filters method is used as a calculated property for the v-for loop in the component:
getters: {
eventsByFilters(state) {
var events = state.events
if (state.search === '' && state.selected) {
switch (state.selected) {
case 'month':
return events.filter(item => this.isMonthEqualNow(item))
case 'week':
return events.filter(item => this.isMonthEqualNow(item) && this.isWeekEqualNow(item))
case 'day':
return events.filter(item => this.isMonthEqualNow(item) && this.isWeekEqualNow(item)
&& this.isDayEqualNow(item))
default:
return events
}
} else {
return events.filter(item => item.title.indexOf(state.search) !== -1)
}
},
I need to use the isMonthEqual and other methods to find out if they belong to certain dates.But I find it difficult to access them:
if I define them in actions, I can't access them, since context is not present in getter;
if I define globally, too, there is no way to access them(this is undefined in this case, and without this, the error that the method is undefined is thrown);