Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

242
Visualizações
how to sum or calculate value in array use vue

i have data array in this

"item_tabel": [
  {
    "method": {
      "select_method": 6,
      
    },
    "innovation": {
      "select_innovation": 2,
    },
  }
],

how to calculate using sum ?

this my computed

subtotalRow() {
    return this.$store.state.item_tabel.map((item,i) => {
      return Number(item.method.select_method * item.innovation.select_innovation)
      //how to sum (item.method.select_method + item.innovation.select_innovation)
     });
 },

example in my table

No | method | inov | total
1  |    6   |  2   | (6+2 = 8) //calculate
2  |    2   |  2   |  4        //calculate 

if using operator * works and if using + doesn't work

thks

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

This should work for you;

Since a callback function is required by Array.map() so the function body is supposed to be enclosed in braces '{}'

subtotalRow() {
    return this.$store.state.item_tabel.map(
        (item,i) => {item.method.select_method + item.innovation.select_innovation}
    );
 },
about 4 years ago · Juan Pablo Isaza Relatório

0

If you really want to add the 6 and 2

Surely all you need to do is what you have written in your comment line?
subtotalRow() {
    return this.$store.state.item_tabel.map(
        (item,i) => (item.method.select_method + item.innovation.select_innovation)
    );
 },
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda