Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

487
Vistas
How to sum total in table vuejs?

There are two rows of data row,

<tr v-for="(data, index) in result_estimate.item_tabel" :key="index">
  <td>
    <pre> sub total : {{ambilaja(formatPrice(ambilPrice[index] - (ambilPrice[index] * subtotalRow[index])))}}</pre>
  </td>
<tr>
<div> total : {{this.totals}}</div>

The result of the above value is the total of each of each row, here I pass the value into the function ambilaja().

 return {
    totals : 0
    },
    computed : (){
         ambilaja: function(){
              return (value) => this.lempar(value)
         },
    }, 
    method : {
       lempar(data){
          console.log(data) 
          result console 
          30002 -> total row index 0
          2003 -> total row index 1
       }
    }

How to add up the total ? ex : 30002 + 2003 = this.totals

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Not sure what type of data is in ambilPrice or subtotalRow but you can just add another method and pass parameters to do calculations.

<tr v-for="(data, index) in result_estimate.item_tabel" :key="index">
  <td>
    <pre> sub total : {{ambilaja(formatPrice(ambilPrice[index] - (ambilPrice[index] * subtotalRow[index])))}}</pre>
  </td>
<tr>
<div> total : {{calTotals(ambilPrice, ambilPrice, subtotalRow)}}</div>

Vue Code:

return {
  totals : 0
  },
  method : {
    calTotals(ambilPriceArr, subtotalRow, index) {
      this.totals = this.totals + ambilPriceArr[index] - (ambilPriceArr[index] * subtotalRow[index]);
      return this.totals;
    },
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

The best approach for this issue is to use computed property for the total as like below.

computed() {
    total: function(){
        let sum = 0;
        this.result_estimate.item_tabel.forEach(item => sum += this.calculatePriceForIndividualRow(item));
        return sum;
    },
},

Where calculatePriceForIndividualRow is the function that will calculate sum for each row.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda