Skip to content

Instantly share code, notes, and snippets.

Created Jan 6, 2019
What would you like to do?
// import Vue
import Vue from 'vue';
// import Vuex
import Vuex from 'vuex';
// Install the Vuex plugin on vue
// create a Vuex store instance
export const store = new Vuex.Store({
state: {
cart: ["bread", "rice", "beans", "turkey"]
getters: {
// Fetch the total number of items in the cart
totalNumberOfCartItems: state => {
return state.cart.length;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment