Mutations and Actions
Change state with mutations and async actions.
Changing State Safely
In Vuex you never modify state directly from a component. Instead, all changes go through mutations. This single, explicit path makes every state change traceable and debuggable in Vue DevTools.
What Is a Mutation?
A mutation is a synchronous function that receives the current state and changes it. Mutations are the only place where state is allowed to be modified.
mutations: {
increment(state) {
state.count++
}
}All lessons in this course
- Vuex Fundamentals
- Mutations and Actions
- Getters and Modules