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

97
Visualizações
transform template v-for into computed

I'm working with BootstrapVue.

I'm looping over an array, check the index of my array (indexArray) with the index of my component (indexChild) and then it should write the value which is in my indexArray in my b-form-input v-model.

How can I transform this code into a computed function? I know that I have to filter it but I don't know how to solve that .

<div v-for="(ID, indexChild) in 3" :key="indexChild">
  <div v-for="(item, indexArray) in Array" :key="indexArray">
    <div v-if="indexArray == indexChild">
      <b-form-input type="number" :v-model="item"></b-form-input> 
    </div>
  </div>
</div>

my Array console.log:

(3) ['1234', '4321', '1379']
 ▼
  0: "1234"
  1: "4321"
  2: "1379"
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Just return an item in your array by index that you already know, no need to iterate:

computed: {
  itemOfInterest(){
    return this.yourArray[this.indexChild]
  }
}

To address the update in the original post. You can still do this in your template

<template>
  <div v-for="(ID, indexChild) in 3" :key="indexChild">
    <b-form-input type="number" :v-model="Array[indexChild]"></b-form-input>
  </div>
</template>

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