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

98
Vistas
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 Respuestas
Responde la pregunta

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 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