Home.vue 592 B

1234567891011121314151617181920212223242526272829
  1. <template>
  2. <div class="home">
  3. <h1>主页</h1>
  4. <div>
  5. <h3>计数器</h3>
  6. <p>C = {{ c }}</p>
  7. <p>2 * C = {{ doubleC }}</p>
  8. <p>
  9. <button @click="add(1)">同步加+</button>
  10. <button @click="asyncAdd(1)">异步加+</button>
  11. </p>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import { mapState, mapGetters, mapActions, mapMutations } from 'vuex';
  17. export default {
  18. name: 'Home',
  19. computed: {
  20. ...mapState(['c']),
  21. ...mapGetters(['doubleC']),
  22. },
  23. methods: {
  24. ...mapMutations(['add']),
  25. ...mapActions(['asyncAdd']),
  26. },
  27. };
  28. </script>