Vue进阶二十四:vuex 之 commit 和dispatch

this.$store.dispatch('toShowLoginDialog',false)
this.$store.commit('toShowLoginDialog', true);

主要区别是:

  • dispatch:含有异步操作,例如向后台提交数据,写法: this.$store.dispatch('action方法名',值)
  • commit:同步操作,写法:this.$store.commit('mutations方法名',值)

延伸阅读

Vue进阶(四十三):Vuex之理解Mutations

Vue进阶(七十三):vuex中store存储store.commit和store.dispatch的区别及用法

相关文章

可以通过min-width属性来设置el-table-column的最小宽度。以...
yarn dev,当文件变动后,会自动重启。 yanr start不会自动重...
ref 用于创建一个对值的响应式引用。这个值可以是原始值(如...
通过修改 getWK005 函数来实现这一点。这里的 query 参数就是...
<el-form-item label="入库类型" ...
API 变动 样式类名变化: 一些组件的样式类名有所变动,可能需...