S
S
Sector5672020-05-01 14:44:06
Vue.js
Sector567, 2020-05-01 14:44:06

Why can't ...mapGetters be unpacked into data?

5eac0ab158a9f416753521.png

Why do you need to unpack in computed , and not like this, for example:

export default {
    data(){
        return{
             ...mapGetters([
                'doneTodosCount',
                 'anotherGetter'
                  // ...
            ])
        }
    }
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Pastukhov, 2020-05-01
@Sector567

From the vuex docks , the mapGetters
function simply proxies the store getters into the component's local computed properties.
That is, it turns intomapGetters(['doneTodosCount'])

{
  doneTodosCount() {
    return this.$store.getters.doneTodosCount;
  },
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question