S
S
Sky6blue2021-07-30 17:47:37
Vue.js
Sky6blue, 2021-07-30 17:47:37

Vuex. what is the correct way to use getters?

Do I need to write a similar getter, or can I just refer to this.$store.state.counter in the component?

export const store = new Vuex.Store({
    state: {
        counter: 0 as number,
    },
    getters: {
        counter: state => () => state.counter,
    },
  });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor L, 2021-07-30
@Sky6blue

Getters are used when it is necessary to display modified information from the storage.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question