This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import Vuex from 'vuex' | |
import state from './state' | |
import getters from './getters' | |
import mutations from './mutations' | |
import actions from './actions' | |
import cart from './modules/cart' | |
Vue.use(Vuex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import Vue | |
import Vue from 'vue'; | |
export default { | |
state: { | |
cart: ["bread", "rice", "beans", "turkey"] | |
}, | |
getters: { | |
// Fetch the total number of items in the cart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import Vuex from 'vuex' | |
import state from './state' | |
import getters from './getters' | |
import mutations from './mutations' | |
import actions from './actions' | |
Vue.use(Vuex) | |
export default new Vuex.Store({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<main> | |
<h1>Cart Content</h1> | |
<p>Total Number of Items: {{totalNumberOfCartItems}}</p> | |
<form @submit.prevent="addItemToCart"> | |
<input type="text" v-model="item" required> | |
<button type="submit">Add to cart</button> | |
</form> | |
<button type="button" @click="checkout">Checkout</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import Vue | |
import Vue from 'vue'; | |
// import Vuex | |
import Vuex from 'vuex'; | |
// Install the Vuex plugin on vue | |
Vue.use(Vuex); | |
// create a Vuex store instance | |
export const store = new Vuex.Store({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<main> | |
<h1>Cart Content</h1> | |
<p>Total Number of Items: {{totalNumberOfCartItems}}</p> | |
<form @submit.prevent="addItemToCart"> | |
<input type="text" v-model="item" required> | |
<button type="submit">Add to cart</button> | |
</form> | |
<button type="button" @click="checkout">Checkout</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import Vue | |
import Vue from 'vue'; | |
// import Vuex | |
import Vuex from 'vuex'; | |
// Install the Vuex plugin on vue | |
Vue.use(Vuex); | |
// create a Vuex store instance | |
export const store = new Vuex.Store({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<main> | |
<h1>Cart Content</h1> | |
<p>Total Number of Items: {{totalNumberOfCartItems}}</p> | |
<form @submit.prevent="addItemToCart"> | |
<input type="text" v-model="item" required> | |
<button type="submit">Add to cart</button> | |
</form> | |
</main> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import Vue | |
import Vue from 'vue'; | |
// import Vuex | |
import Vuex from 'vuex'; | |
// Install the Vuex plugin on vue | |
Vue.use(Vuex); | |
// create a Vuex store instance | |
export const store = new Vuex.Store({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<main> | |
<h1>Cart Content</h1> | |
<p>Total Number of Items: {{totalNumberOfCartItems}}</p> | |
</main> | |
</template> | |
<script> | |
export default { | |
computed: { |
NewerOlder