vue store 存储 dispatch 和 commit的区

2019-05-23  本文已影响0人  xukuangbo_

dispatch: 含有异步操作

存储:

this.$store.dispatch('initUserInfo',friend);

取值:

this.$store.getters.userInfo;

commit:同步操作

存储:

this.$store.commit('initUserInfo',friend);

取值:

this.$store.state.userInfo;
上一篇 下一篇

猜你喜欢

热点阅读