簡單的理解:
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' }) }