1.state 2.mutations 3.getters 4.actions 5.modules
1.state
组件访问:this.$store.state.xxx
2.mutations
mutation的名字(state,形参){
}
组件访问:this.$store.commit('mutation的名字',实参) ->多个参数用对象包住
3.getters
getter的名字(state){ return state.xxx.xxx
}
组件访问:this.$store.getters.getter的名字
4.actions
action的名字(context,形参){
//如果要调用mutation
context.commit('mutation的名字', 实参)
}
组件访问:this.$store.dispatch('action的名字', 实参)
5.modules
组件访问:this.$store.state.模块名.xxx
组件访问:this.$store.commit('模块名/mutations名',实参) ->多个参数用对象包住
组件访问:this.$store.getters['模块名/getters名']
组件访问:this.$store.dispatch('模块名/actions名',实参)
Map辅助函数
1.state
2.getters
3.methods
4.actions