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
Dividing lines are a common type of design on web...
Preface Generator functions have been in JavaScri...
The property names often heard in web design: con...
1. Introduction to Navicat 1. What is Navicat? Na...
MySQL is the most popular relational database man...
Table of contents 1. Download MySQL 2. Install My...
If there is a table product with a field add_time...
Are you still using rem flexible layout? Does it ...
The importance of data consistency and integrity ...
I have read a lot of knowledge and articles about...
Today when I was writing a flash advertising code,...
<br />When thoughts were divided into East a...
The three-dimensional column chart consists of th...
Effect: When the slideshow moves in one direction...
This article introduces the flex layout to achiev...