//App.vue
<template>
<div id="app">
{{ count }}<br/>
<button @click="increment">+1</button><br/>
<button @click="incrementBy(5)">+5</button><br/>
</div>
</template>
<script>
import { mapState, mapMutations } from 'vuex';
export default {
name: 'App',
computed: mapState([
'count'
]),
// methods: {
// increment () {
// this.$store.commit('increment');
// },
// incrementBy () {
// this.$store.commit('incrementBy', 5);
// },
// decrement () {
// this.$store.commit('decrement', { amount: 1});
// },
// decrementBy () {
// this.$store.commit({
// type: 'decrementBy',
// amount: 5
// });
// }
// }
methods: mapMutations([
'increment',
'incrementBy'
])
}
</script>
05笔记vuex mutation02
猜你喜欢
转载自blog.csdn.net/qq_25479327/article/details/104200591
今日推荐
周排行