Vuex is a state management model developed specifically for Vue.js applications; it uses centralized storage to manage the state of all components of the application, and uses corresponding rules to ensure that the state occurs in a predictable way. Variety. Vuex can manage the data status of complex applications, such as communication between sibling components, value transfer among multi-layer nested components, etc.
Vuex is a state management pattern developed specifically for Vue.js applications. It uses centralized storage to manage the state of all components of the application, and uses corresponding rules to ensure that the state changes in a predictable way.
Vuex is also integrated into Vue’s official debugging tool devtools extension, providing advanced debugging functions such as zero-configuration time-travel debugging, state snapshot import and export, etc.
Vue uses centralized storage to manage the status of all components of the application. The key here is centralized storage management. This means that updates that originally required shared state required communication between components, but now with vuex, components all communicate with the store. This is why the official website once again mentions the value of Vuex in building large applications. If you don’t plan to open a large single-page application, using Vuex may become very cumbersome. For large projects, you can use Vuex as the state between different components. Management, and for small projects, it is recommended to use HTML5-specific attributes, localStroage and sessionStroage as data transfer.
vuex has several core concepts: State, Getter, Mutation, Action, and Module.
state stores the state we mentioned above
mutations stores how to change the state
getters derives the state from the state, such as Filter a certain state in the state and obtain the new state.
Actions is an enhanced version of mutation. It can change the state through the methods in commit mutations. The most important thing is that it can perform asynchronous operations.
modules As the name suggests, when using this container to store these states is still confusing, we can divide the container into several pieces and classify the states and management rules to install them. This is the same purpose as when we create js modules to make the code structure clearer.
【Related recommendations: JavaScript video tutorial】
The above is the detailed content of What is vuex?. For more information, please follow other related articles on the PHP Chinese website!