当前位置: 代码迷 >> 综合 >> this.$store.dispatch() 与 this.$store.commit()方法的区别
  详细解决方案

this.$store.dispatch() 与 this.$store.commit()方法的区别

热度:3   发布时间:2024-01-24 09:31:09.0

我查了别人的博客,很多都很笼统,还是不怎么清除,总的来说他们只是存取方式的不同,两个方法都是传值给vuex的mutation改变state
commit: 同步操作
存储

this.$store.commit('changeValue',name)

取值

this.$store.state.changeValue

dispatch: 异步操作
存储

this.$store.dispatch('getlists',name)

取值

this.$store.getters.getlists
  相关解决方案