vue store存储commit 和dispatch的区别

版权声明:未经本人同意不得私自转载 https://blog.csdn.net/qq_40190624/article/details/85289322

dispatch:含有异步操作,

存储:

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

取值:

this.$store.getters.targetUser;

commit:同步操作,

存储:

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

取值:

this.$store.state.setTargetUser

猜你喜欢

转载自blog.csdn.net/qq_40190624/article/details/85289322