vue vuex使用注意

1 在页面中注入了store 每个实例都会存在一个属性$store
2 子模块的状态 $store.state.user.userName 模块.属性
3 假如在vuex中用到模块 最好使用辅助方法,
如果有子模块,mapState,mapActions,mapMutations不要把子模块放前面例如:
...mapActions('user',['change_uname'],['change']),这样不能识别出来要像如下设置
...mapActions(['change'],'user',['change_uname'])这样可以识别到了

猜你喜欢

转载自www.cnblogs.com/zhx119/p/11408139.html