Home  >  Article  >  What are the five core attributes of vuex

What are the five core attributes of vuex

王林
王林Original
2021-06-11 17:13:264496browse

The five core attributes of vuex are state, getters, mutations, actions and modules. State is the basic data of vuex, which is used to store variables. Geeter is data derived from basic data, which is equivalent to the calculated attribute of state.

What are the five core attributes of vuex

The operating environment of this article: windows10 system, vue 2.5.2, thinkpad t480 computer.

The five core attributes in Vuex are: state, getters, mutations, actions, modules.

Let’s take a look at these five attributes.

state: basic data of vuex, used to store variables

geeter: data derived from basic data (state), equivalent to the calculated attribute of state

mutation: Submit The method of updating data must be synchronous (if you need to use action asynchronously). Each mutation has a string event type (type) and a callback function (handler).

The callback function is where we actually change the state, and it will accept state as the first parameter and submit the payload as the second parameter.

Action: The function is roughly the same as mutation. The difference is ==》1. Action submits a mutation instead of directly changing the state. 2. Action can contain any asynchronous operation.

modules: Modular vuex allows each module to have its own state, mutation, action, and getters, making the structure very clear and easy to manage.

Related video sharing: Programming video

The above is the detailed content of What are the five core attributes of vuex. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn