vue.jsのcomputedプロパティと同じように関数を定義できる。 複数のコンポーネントで同じ関数を使いたい時に一箇所に定義することができ便利。 設定はstateと同じくstore.jsに記述する。
export default new Vuex.Store({ state: { count: 2 }, getters: { dobuleCount: state => state.count * 2, tripleCount: state => state.count * 3 } });
vue.jsのcomputedプロパティと同じように関数を定義できる。 複数のコンポーネントで同じ関数を使いたい時に一箇所に定義することができ便利。 設定はstateと同じくstore.jsに記述する。
export default new Vuex.Store({ state: { count: 2 }, getters: { dobuleCount: state => state.count * 2, tripleCount: state => state.count * 3 } });