Article From:

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

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'

const store = new Vuex.Store({
  state: {
     count: 0

new Vue({
  el: '#app',

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 *