Article From:https://www.cnblogs.com/Richard-Tang/p/9967506.html

VuexIt can be understood as a Vue global data warehouse, using Vuex can easily transfer data in various components, no longer need to pass values through the way of $emit and binding parameters.

The scaffolding method is used to install Vuex https://vuex.vuejs.org/


I. installation

npm install vuex -S

2. Find the main.js file of scaffolding

 

3. Writing corresponding codes

import Vue      from 'vue'
import Vuex     from 'vuex'

Vue.use(Vuex)
const store = new Vuex.Store({
  state: {
     count: 0
  }
})

new Vue({
  el: '#app',
  store
})

Note that after the introduction of the Store object must be registered, registered to the Vue instance, if not registered, only the current. JS file can be used.

 

Link of this Article: Using vuex in vue-cli

Leave a Reply

Your email address will not be published. Required fields are marked *