What is Vuex? VueX is a state management framework designed specifically for Vue.js applications, which uniformly manages and maintains the mutable states of various vue components (you can understand it as some data in the vue component). Vuex can be understood as a development mode or framework. For example, PHP has thinkphp, Java has spring, and so on. Centrally manage changes in driver components through state (data source) (just like Spring's IOC container centrally manages beans). Vuex has five core concepts: Application-level state is centralized in the store; the way to change the state is to submit mutations, which is a synchronous thing; asynchronous logic should be encapsulated in actions. Cuex draws on Flux, Redux, and The Elm Architecture. Unlike other modes, Vuex is a state management library designed specifically for Vue.js to utilize Vue.js's fine-grained data response mechanism for efficient state updates. State management : Simply put, it is to uniformly manage and maintain the changeable states of each vue component (you can understand it as some data in the vue component) Five properties of Vuex
What is the State property of vuex? 1. Vuex is a warehouse, which contains many objects. The state is where the data source is stored, corresponding to the data in the general Vue object. 2. The data stored in the state is responsive. Vue components read data from the store. If the data in the store changes, the components that depend on this data will also be updated. 3. It maps the global state and getters to the computed properties of the current component through mapState. What is the Getter feature of vuex? 1. Getters can perform calculations on State, which is the calculated property of Store 2. Although you can also calculate properties within a component, getters can be reused between multiple components 3. If a state is only used in one component, getters are not required. What is the mauation feature of vuex? 1. A mutation is an object that contains multiple methods (callback functions) that directly update the state. 2. Only synchronous code can be included, and asynchronous code cannot be written What is the action feature of vuex? 1. Action is similar to mutation, but the difference is: 2. Action submits a mutation instead of directly changing the state. 3. Action can contain any asynchronous operation When should I use Vuex? Although Vuex can help us manage shared states, it also comes with more concepts and frameworks. This requires weighing short-term and long-term benefits. If you don't plan to develop a large single-page application, using Vuex may be cumbersome and redundant. It's true - if your app is simple enough, you're probably better off not using Vuex. A simple global event bus is all you need. However, if you need to build a medium to large single-page application, you will most likely consider how to better manage the state outside the component, and Vuex will become a natural choice. SummarizeThis article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: Don’t bother with JavaScript if you can do it with CSS
>>: 7 skills that web designers must have
Recently, there is a requirement for uploading pi...
JavaScript now releases a new version every year,...
There are two common ways to download files in da...
Table of contents 1. What is lazy loading of rout...
Table of contents background Problem Description ...
Nowadays, whether you are on the sofa at home or ...
Frameset pages are somewhat different from ordina...
1. Setting up nginx virtual host With virtual hos...
Table of contents verify: Combined with the examp...
A few months after entering the industry in 2005, ...
Table of contents Conditional compilation Page La...
1. Call the parent component method directly thro...
The new official website is online, but the exper...
Preface The most common task after we install a L...
Linux change hostname command 1. If you only need...