[Vuejs]-Vue.js sum of keys after applying filterBy

2👍

Why not this

https://jsfiddle.net/f5d16skc/

computed: {
    filteredClients: function () {
    return this.clients.filter(c => c.name.indexOf(this.query) !== -1)
  },
  totalCoins: function () {
    return this.filteredClients.reduce((a, b) => a + b.coins, 0)
  }
}

Remember: never use filters in v-for! It’s deprecated.

Leave a comment