Vuex 在使用 Mutation handler 显示unknown action type:
 发布于 9 年前  作者 MaskWu  18018 次预览  最后一次回复是 9 年前  来自 问答 

正在学习Vuex,今天对照了文档中的实例写了一下,发现无法完成文档中的功能,并报错

[vuex] unknown action type: INCREMENT

示例代码如下:

import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex)
const store = new Vuex.Store({
    state: {
        count: 0
    },
    mutations: {
        INCREMENT (state) {
            // 改变 state
            state.count++
        }
    }
})

store.dispatch('INCREMENT');
console.log(store.state.count)

google了一下没有发现这方面的信息,所以想请问一下,有没有人遇到过这样的情况,以及解决办法是怎样的

1 回复
qq799155469

你需要一个action