Skip to content

Instantly share code, notes, and snippets.

@mfaridzia
Last active April 2, 2018 16:06
Show Gist options
  • Save mfaridzia/e47cec0681b5aa6988637bf037f86bd2 to your computer and use it in GitHub Desktop.
Save mfaridzia/e47cec0681b5aa6988637bf037f86bd2 to your computer and use it in GitHub Desktop.
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