[Vuejs]-How to sum values in VueJs

0👍

If the formData.products is correctly setting the values selected, then you can directly get the sum of values from the computed section.

computed:{
  sum : function(){
    let products = this.formData.products;
    return products.reduce((a,b)=>{
      return parseFloat(a.price) + parseFloat(b.price);
    })
  }
}

Leave a comment