[Vuejs]-Vuejs computed or methods: which one is best to use vuex getters?

0👍

You should map your getters inside your components so they are not computed twice but instead reference the method in the getter.

import { mapGetters } from 'vuex'

export default {
  // ...
  computed: {
    // mix the getters into computed with object spread operator
    ...mapGetters([
      'doneTodosCount',
      'anotherGetter',
      // ...
    ])
  }
}

more info can be found here:
https://vuex.vuejs.org/guide/getters.html#the-mapgetters-helper

Leave a comment