MiloudiMohamed
7 months ago
39
4
Vue

Sum up an attribute from children components

Posted 7 months ago by MiloudiMohamed

Hello I have two components supplies and supply I do a v-for inside the supplies so I create many of the supply children

<supply
  v-for="supply in supplies"
  :supply="supply"
  :key="supply.id"
 ></supply>

And inside the supply I can choose a quantity and multiply it by the supply.price to get the total

computed: {
  total () {
      return this.supply.price * this.quantity
  }
}

What I want to know is how can I sum all the total from all the supply component

Thank you in advance

Please sign in or create an account to participate in this conversation.