vue-cli install and create a simple project (b) (vuex use)

1.vuex use

  vuex is vue state management center, vuex to hold our need to manage state value, the value is modified once, all of the local reference value will automatically update, commonly used in:

1. The plurality of views dependent same state (L Example: menu navigation)

2. behavior from different views of the same state needs to be changed (such as reviews barrage)

 

  On the one we already have vuex module is installed. View store / index.js directory, as follows:

Import View from 'view' ;
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
  },
});

  The above modules and introducing Vue Vuex module, and installed in Vue Vuex.

 

Use the following vuex.

 

Guess you like

Origin www.cnblogs.com/qlqwjy/p/11938755.html