<div>{{num}}</div>
<button @click="add">++</button>
<script>
import { mapState, mapMutations } from "vuex";
export default {
name: 'HomeIndex',
components:{
SaleCard
},
computed:{
...mapState(['num']),
},
methods:{
add(){
this.$store.commit('madd')
}
...mapMutations(["madd"]),
}
}
</script>
const store = new Vuex.Store({
state:{
num:22
},
mutations:{
madd(state){
state.num++
}
},
actions:{
}
})