You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<template> <div> <h1>vuex 测试</h1> Clicked: {{ getCount }} times <button @click="increment">+</button> <button @click="decrement">-</button> </div> </template>
<script> import { mapGetters } from 'vuex' import { mapActions } from 'vuex'
export default { computed: { // 使用对象展开运算符将 getters 混入 computed 对象中
...mapGetters([ 'getCount' // ...
]) }, methods: { ...mapActions([ 'increment', // 映射 this.increment() 为 this.$store.dispatch('increment')
'decrement' ]) //...mapActions({
// add: 'increment' // 映射 this.add() 为 this.$store.dispatch('increment')
//})
} } </script>
|