<template> <div class="hello"> <p>{{count}}</p> <p> <button @click="increment">+</button> <button @click="decrement">-</button> <button @click="incrementIfOdd">Increment if odd</button> <button @click="incrementAsync">Increment async</button> </p> </div> </template> <script> import {mapGetters,mapMutations,mapActions} from 'vuex' export default { name: 'hello', data () { return { msg: 'Welcome to Your Vue.js App' } }, computed:{ ...mapGetters([ 'count', 'evenOrOdd' ]) }, methods:{ increment(){ this.$store.dispatch('increment') }, decrement(){ this.$store.dispatch('decrement') }, incrementIfOdd(){ this.$store.dispatch('incrementIfOdd') }, incrementAsync(){ this.$store.dispatch('incrementAsync') } } } </script>

 

posted on 2018-01-03 14:15  执候  阅读(254)  评论(0编辑  收藏  举报