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...