Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the properties of vuex

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge points about the attributes of vuex. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

The attributes of vuex are: 1, state, used to store variables; 2, mutations, the method of submitting updated data; 3, actions, used to solve asynchronous processes to change state data; 4, getters, filtering variables in state; 5, modules.

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

What is Vuex?

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 changes in a predictable way. Vuex is also integrated into Vue's official debugging tool devtools extension, providing advanced debugging features such as zero configuration time-travel debugging, status snapshot import and export, and so on.

There are five particularly important attributes in Vuex, which are state,mutations,actions,getters,modules.

Five attributes of vuex

1.state

To place state-related information, vue uses a single state tree, that is, a single data source, that is, our state can only have one.

2.mutations

Mutations is actually equivalent to the methods in our vue, which also defines a method, but this method can be called in multiple components.

He called it like this: use our commit

Finally, just use it:

3.actions

Mutations writes synchronous operations, but asynchronous operations cannot be written in it, so we need to write our asynchronous operations in actions. And if you write asynchronous operations, you won't use commit if you call it. Instead, use our dispatch

As shown in the figure above, we first write our methods in mutations, then write asynchronous operations in actions, then call the methods we wrote in mutations, and then go back to our component and use our dispatch in the component.

4.getters

Getters is actually equivalent to the calculation properties in vue, we use some calculation methods in this, it is also quite easy to use, just need to use it directly in the component. The operation is as follows.

5.modules

The last one is our modules, which means modularization, because it is a single state tree, afraid that we write too much in the state, it is difficult to find, then we can redefine one of our modules in our modules, which is equivalent to a store, which also has the five attributes we need, and the operation is the same.

These are all the contents of the article "what are the attributes of vuex?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report