Current location - Education and Training Encyclopedia - Resume - Introduction and use of uni-appVuex
Introduction and use of uni-appVuex
Whether you use HX or vue-cl i to create the uniapp project, Vuex is already built in, so there is no need to install it again.

Uni-app also has globalData similar to applets, which is a simple global variable mechanism.

GlobalData is a simple global variable. If you use state management, please use vuex.

Project file structure

1. Import storage file in main.js

2. Assemble the module and export the storage.

3. Define cart.js module (take shopping cart as an example here)

4. Define getters at the root level

use

Check the effect

Click the Add button.