March 2018
Beginner to intermediate
344 pages
7h 7m
English
Let's start off by creating a file named index.js inside src/store. This is the file we'll use to create our new store and bring together the various components.
We can start by importing both Vue and Vuex as well as telling Vue that we'd like to use the Vuex plugin:
import Vue from 'vue';import Vuex from 'vuex';Vue.use(Vuex);
We can then export a new Vuex.Store with a state object that contains all of our application states. We're exporting this so that we can import the state in other components when necessary:
export default new Vuex.Store({ state: { count: 0, },});
Read now
Unlock full access