35 lines
797 B
Vue
35 lines
797 B
Vue
<!--moguyun-->
|
||
<template>
|
||
<div>
|
||
<h3>当前最新的count值为:{{$store.state.countOptions.count}}</h3>
|
||
<button @click="addcount">+1</button>
|
||
<button @click="btnhandle">+1 Async</button>
|
||
<button @click="btnhandle1">+5 Async</button>
|
||
<h3>{{$store.getters['countOptions/showNum']}}</h3>
|
||
</div>
|
||
</template>
|
||
|
||
<script>
|
||
export default {
|
||
data() {
|
||
return {
|
||
|
||
}
|
||
},
|
||
methods: {
|
||
addcount(){
|
||
this.$store.commit('countOptions/add')
|
||
},
|
||
//异步让count自增1
|
||
btnhandle(){
|
||
//dispatch函数专门用来触发action
|
||
this.$store.dispatch('countOptions/addAsync')
|
||
},
|
||
btnhandle1(){
|
||
this.$store.dispatch('countOptions/addNAsync',5)
|
||
}
|
||
},
|
||
|
||
}
|
||
</script>
|