[Vuejs]-VueJS โ€“ calling method in v-for loop, get error 'not defined on the instance but referenced during render'

0๐Ÿ‘

โœ…

You are not using mapState in a correct way.
Change this:

computed: mapState(["filters", "categories"])

into

computed: { ...mapState(["filters", "categories"]) }

For further information, you can check:

https://forum.vuejs.org/t/dont-understand-how-to-use-mapstate-from-the-docs/14454

0๐Ÿ‘

You should to return something from your function and assign a initial value to your collectionsTotal variable:

getCollectionTotal(cat) {
  let collectionsTotal = ''; // or let collectionsTotal = 0;
  collectionsTotal += cat.collections_number;
  return collectionsTotal;
}

Leave a comment