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

237
Vistas
pass value to <input> after every for loop in methods

I'm working with BootstrapVue.

I have a for loop where I get unique numbers of a array these are named this.number - I input.push() my b-form-input (in this example) 3 times.

Every time I'm inputing a new b-form-input I want to pass the first and then of course my next number of this.number to my input that it will be shown there.

How can I do that? Thank You!

template:

<div v-for="(id, index) in inputs" :key="index">
  <b-form-input type="number" v-model="id.number" :value="id.number" @input="searchNumber(id, index)" ></b-form-input>
</div>

my script:

methods: {
  inputValue() {
    for (let i = 0; i < 3; i++) {
      this.number= (String(this.data[i].number));
      this.inputs.push({});

      console.log(this.number);
    }
  }
},

data() {
  return {
    inputs: [{}],
  }
},

my console.log(this.number)

1111
2222
3333

So 1111 should be v-model/value of b-form-input 0, 2222 should be v-model/value of b-form-input 1 and 3333 should be v-model/value of b-form-input 2

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

0

From what I understood what you are trying to do is:

  1. Render 3 inputs
  2. When user inputs in input number 2 it updates the input number 2

You have your code organized in a way that is difficult to follow what is going on. My suggestion is to have a function that is triggered when an input emits a input event and then pass the index (almost what you have with searchNumber)

<div v-for="(id, index) in inputs" :key="index">
  <b-form-input type="number" :value="id.number" @input="onInput($event, index)" ></b-form-input>
</div>
methods: {
  onInput(input, index) {
    this.inputs[index].number = input;
  }
}

Note that I have removed v-model from your b-form-input. Now we only have value and @input.

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