What is vuex? The workflow of vuex?

1. What is vuex?

Vuex is a state management warehouse, which can realize centralized management of the public state of multiple components. It contains five attributes of state, getters, mutations, actions, and modules.

state: used to store and maintain the public state of components,

Getters: Used to process and return the data in the state, similar to computed properties,

mutations: It is the only way to modify the state, and it is a synchronous operation.

actions: actions to be performed, which can be synchronous or asynchronous events,

modules: Multiple warehouse configuration objects can be stored inside, used to divide the warehouse into modules

2. The workflow of vuex

First submit an action through dispatch. After the action receives the event, perform some asynchronous or synchronous operations in the action, and distribute it to different mutations according to the situation. Actions trigger mutations through commit, and then mutations update the state. After the state is updated , Vue will be notified to render. Proceed as follows:

1. Submit an action through dispatch

2. After actions receive events, perform some synchronous or asynchronous operations in actions

3. Distribute to different mutations according to different situations, and actions trigger mutations through commit

4.mustations will update the state after triggering

5. After the state is updated, Vue will be notified to render

おすすめ

転載: blog.csdn.net/LLL3189860667/article/details/127162971