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
v-for over array and set input

I'm looping over a json in my template which works well.

Now I have an array which you can see down below and I want to loop over this array and want to input the first number into my first b-form-input v-model and :value, the second in the second b-form-input and so on.

So my indexChild is equal to the place of number which should be inputed. (indexChild = 0 <-> place of number in my array = 0 -> Input: 7011412)

How I'm able to solve that?

<template>
  <div v-for="(item, indexChild) in json" :key="indexChild">
    <div class="mt-2">Input</div>
    <!-- v-for="item in array" :key="item" --> <!-- this doesn't work! -->
    <b-form-input v-model="???" :value="???" type="number"></b-form-input> 
  </div>
</template>

my array:

['7011412', '7012912', '7689012']

looks like this in console: enter image description here

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

0

You could just set the v-model and value to json[indexChild]
Then your v-model is set to the value of the array at the given index

<div v-for="(item, indexChild) in json" :key="indexChild">
   <div class="mt-2">Input</div>
   <!-- v-for="item in array" :key="item" --> <!-- this doesn't work! -->
   <b-form-input v-model='json[indexChild]' :value="json[indexChild]" type="number"></b-form-input> 
</div> 
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