1.vuex

Vuex is a 'state management mode' developed specifically for vue.js applications. It uses centralized storage to manage the state of all components of the applicationCopy the code

1.1 attributes

2. state, 2. getters, 2. mutations, 2. actions, 3. modules. (Multiple modules, allowing each module to have its own state, mutation, action and getters, making the structure very clear and easy to manage)Copy the code

2. Create a file

Create a store folder under the directory, and create a store.js file under itCopy the code

Introduced 3.

3.1 Used in main.js

4. Write data in store.js

5. Transfer data

5.1

This. codestore.com MIT (' AD ',1) method for passing parameters' AD 'for the passed method name 1 for the passed data define logic in mutations:Copy the code

6.Action handles asynchrony

Modules structure is very clear, easy to manage

7.1

Can use multiple modules to define the different needs of the content and index, js, identical: state, getters, mutations, the actions, in the index. Js inside can be introduced, for development. You don't have to define too much data in the same fileCopy the code

A brief introduction to vuex.