Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!