vuex 五步走:
1. npm install vue -S
2. vue.use(Vuex)
3. 创建一个store模块,定义状态管理的规则 state,mutations,actions,getters,module
4. 把store模块注册到viewmodel
5. this.$store 来访问这个 store
mapGetters把store中的getter方法映射到组建中的computer属性上
mapActions
mapMutations
mapState
dispatch("事件")
原文:https://www.cnblogs.com/manban/p/11105437.html