1import { mapGetters } from 'vuex'
2
3export default {
4 // ...
5 computed: {
6 // mix the getters into computed with object spread operator
7 ...mapGetters([
8 'doneTodosCount',
9 'anotherGetter',
10 // ...
11 ])
12 }
13}
14
1const store = new Vuex.Store({
2 state: {
3 todos: [
4 { id: 1, text: '...', done: true },
5 { id: 2, text: '...', done: false }
6 ]
7 },
8 getters: {
9 doneTodos: state => {
10 return state.todos.filter(todo => todo.done)
11 }
12 }
13});
14
15console.log(store.state.getters.doneTodos);
16// -> [{ id: 1, text: '...', done: true }]