//html
<div id="app">
{{ count }}
<button @click="increment">+</button>
<button @click="decrement">-</button>
</div>
//js
// make sure to call Vue.use(Vuex) if using a module system
const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
increment: state => state.countPP,
decrement: state => state.count--
}
})
new Vue({
el: "-sharpapp",
computed: {
count () {
return store.state.count
}
},
methods: {
increment () {
store.commit("increment")
},
decrement () {
store.commit("decrement")
}
}
})
in the above code,
<button @click="increment">+</button>
<button @click="decrement">-</button>
Why not methods.increment ()?