Vue store 存储commit 和dispatch区别

Vue store 存储commit 和dispatch区别

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

主要区别是:

1、dispatch:含有异步操作,例如向后台提交数据,写法:this.$store.dispatch('mutaions方法名',值)

2、commit:同步操作,写法:this.$store.commit('mutions方法名',值)

 

posted @ 2019-08-29 18:07  jiachunhui  阅读(515)  评论(0编辑  收藏  举报