Please enable JavaScript.
Coggle requires JavaScript to display documents.
vuex - Coggle Diagram
vuex
Mutation
type & handler
increment(state) {state.count ++}
store.commit('increment')
Vue 的响应规则
Mutation event Constant
mapMutations
Actions
提交的是 mutation,而不是直接变更状态。
store.dispatch('increment')
able async
mapActions
State
computed: {count() { return store.state.count }}
this.$store.state.count
mapState
Getters
find
getTodoById: (state) => (id) => {return state.todos.find(todo => todo.id === id}
mapGetters
filter
doneTodosCount() { return this.$store.todos.filter(todo => todo.done).length }
Modules
Vuex 允许我们将 store 分割成模块(module)
namespaced