简单的理解:

const getters = {
newCount: function(state){
return state.count += 5;
}
}
---------------------------------------
组件中获取

methods: {
newCount: function(){
return this.store.getters.newCount;
}
}
------------------------------------------
import { mapGetters } from 'vuex'
computed: {
...mapGetters(['count'])
}
当getters中的属性和组件节点的属性相同时可以通过mapGetters辅助函数的数组参数来赋值 如果你想将一个 getters 属性另取一个名字,可以使用对象形式:
computed: {
...mapGetters({
counts: 'count'
})
}
05-27 21:28