this.$store.dispatch() 和 this.$store.commit()的本质是存取方式的不同,两个方法都是传值给vuex的mutation改变state
commit: 同步操作
存值 this.$store.commit(‘state变量/state方法返回的值’,name)
取值 this.$store.state.changeValue
dispatch: 异步操作
存值 this.$store.dispatch(‘state变量/state方法返回的值’,name)
取值 this.$store.getters.getlists
demo示例可以查看如下参考文献
vuex详解参考文献如下
版权声明:《 vuex中如何区分及使用 this.$store.dispatch() 和 this.$store.commit() 》为漠北星火原创文章,转载请注明出处!
最后编辑:2020-11-2 10:11:40