What does Vuex do

1. Vuex is a state management mode specially developed for VUE, JS applications

Vuex core concepts

1).State

2).Getters

3).Mutation

4).Action

5).Module

Note: Mutation only implements synchronous and not asynchronous operations

  • – The store state must have been changed by mutation

2. The count of vue

1. Extract a common store object that protects shared state across multiple components

2 Place the store object in the newVue object to ensure that all components are not available

3 Access the state through this,$store, and state attributes

Use this. Codestore.mit (‘ method in mutataion ‘) to modify

The English name Of the Single state tree is Single source Of Truth, which can also be translated as Single data source

Vuex can not have a lot of store inconvenient later maintenance

The state in the Store of VUex is responsive. When the data in the state changes, When adding new properties to objects in state, use vue.set(obj,’newProp’,123). Use vue. Reassign an old object with a new object

Set (object to be modified, index value,, modified value)

In mutation, many event types (i.e. method names) were defined. As the project grew, more and more states were managed by Vuex, and more and more states needed to be updated, which meant that there were more and more mutation methods. Users need to spend a lot of effort to remember this method, even when multiple files, etc., there will be errors

In general, vuEX requires that the methods in our mutation be synchronized because devTools can help us capture the mutation snapshot when we use devTools

The context context

Why do we use a single state tree in Vuex, which means that a lot of states will be managed by Vuex

When we get very complex, the Store object can become quite bloated. To solve this problem, Vuex allows us to split the store into modules (each Module has its own state, mutations, action, getters, etc.)