What is Vuex?
Official explanation: Vuex is a state management model + library specially developed for Vue.js applications
Concept: It is a Vue plug-in that is specially implemented in Vue to implement centralized state (state is also data), and manages the shared state of multiple components in Vue applications in a centralized manner (the operation of data is nothing more than two kinds of read/write) , is also a way of communication between components, and is suitable for any communication between components
When to use Vuex? (To put it bluntly, when you need to share data)
1. Multiple components depend on the same state
2. Behaviors from different components need to change the same state
In Vue2, version 3 of vuex should be used
Example:
The code to install version 3 of vuex in Vue2 is
npm i vuex@3
In Vue3, version 4 of vuex should be used