1234567891011121314151617181920212223242526272829 |
- <template>
- <div class="home">
- <h1>主页</h1>
- <div>
- <h3>计数器</h3>
- <p>C = {{ c }}</p>
- <p>2 * C = {{ doubleC }}</p>
- <p>
- <button @click="add(1)">同步加+</button>
- <button @click="asyncAdd(1)">异步加+</button>
- </p>
- </div>
- </div>
- </template>
- <script>
- import { mapState, mapGetters, mapActions, mapMutations } from 'vuex';
- export default {
- name: 'Home',
- computed: {
- ...mapState(['c']),
- ...mapGetters(['doubleC']),
- },
- methods: {
- ...mapMutations(['add']),
- ...mapActions(['asyncAdd']),
- },
- };
- </script>
|