vuex中 this.$store.dispatch() 与 this.$store.commit()方法的区别
存取方式不同:
-
this.$store.commit():同步操作
存储:this.$store.commit(‘mutations方法名’,值)
取值:this.$store.state.方法名
-
this.$store.dispatch():异步操作
存储:this.$store.dispatch(‘action方法名’,值)
取值:this.$store.getters.方法名
相同点:
都是传值给vuex的mutation改变state数据