vuex module
* 如果模块名称为:company
* state: { ... }, // this.$store.state.company.xxx
getters: {
isAdmin () { ... } // -> this.$store.getters['company/isAdmin']
},
actions: {
login () { ... } // -> this.$store.dispatch('company/login')
},
mutations: {
login () { ... } // -> this.$store.commit('company/login')
}
// 开启命名空间
namespaced: true,
mapState
import { mapState } from 'vuex'
computed: {
...mapState({
age: state => state.A.age,
bAge: state => state.B.age,
name: state => state.B.name
})
}