Getters with Parameters
While Getters can be accessed directly via $store.getters
properties, you may run into situations where you need a bit more control over how the getter works. Parameters provide a way to customize how Getters works. Consider the following store:
import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) export default new Vuex.Store({ state: { books:[ {type:'nonfiction', title:'Truth about Cats', pages: 200}, {type:'nonfiction', title:'Truth about Dogs', pages: 100}, {type:'fiction', title:'The Cat Said Meow', pages: 400}, {type:'fiction', title:'The Last Dog', pages: 600}, ] }, getters: { fiction(state...