vuex核心概念Getters
Getters用于对store中的数据进行加工处理形成新的数据
获取getters有两种方法
首先定义getters
state: {
count: 0
},
getters: {
showCount(state) {
return '当前的count值为' + state.count
}
}
第一种获取getters数据
this.$store.getters.showCount
第二种方法
<h1>{{showCount}}</h1>
import { mapGetters } from 'vuex'
computed: {
...mapGetters(['showCount'])
},