明明按步骤写的vuex的actions方法,为什么会报错未知呢?原来没有加上命名空间的名字
[vuex] unknown action type: countAddAction-QUI-Notes

vuex的actions方法如下:

namespaced: true,
state: {
        content: 0,
},
...
actions: {
        countAddAction(context){
            context.commit("add")
        },
        countCubtractAction(context){
            context.commit("subtract")
        }
}

外部更改content的值:

就可以用dispatch调用actions里的方法

this.$store.dispatch('count/countAddAction');

也可以直接修改

this.$store.count.content++

这样就可以修改vuex的state对应的值了,自己搭建环境很容易忘啊,发现一直在学基础和忘基础的路上,脑子不好使了,离退休不远了吧。