Last active
April 2, 2018 16:06
-
-
Save mfaridzia/e47cec0681b5aa6988637bf037f86bd2 to your computer and use it in GitHub Desktop.
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' | |
Vue.use(Vuex) | |
export default new Vuex.Store({ | |
state: { | |
count: 0 | |
}, | |
getters: { | |
getCounter: state => { | |
return state.count | |
} | |
}, | |
mutations: { | |
increment (state) { | |
state.count++ | |
}, | |
decrement (state) { | |
if(state.count > 0) { | |
state.count-- | |
} | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment