vuexまとめ
vuexの書き方をよく忘れるからまたまとめる。
const モジュール名 = { namespaced: true, state: { キー: バリュー , }, mutations: { メソッド名(state) { 処理 } }, } export default new Vuex.Store({ modules: { モジュール名, }, })
<script> import { mapState } from 'vuex' export default { computed: { ...mapState('モジュール名',[ '変数名' ]), }, methods: { メソッド名() { this.$store.commit('モジュール名/メソッド名) }, } }; </script>