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

147
Views
How to show a property from an object inside an array in Vue data during a loop defined on the Template?

My data structure:

data: {
    OBJs: [ 
        { "imageUrl": "site/image1.png", "name": "name1" }, 
        { "imageUrl": "site/image2.png", "name": "name2" }, 
        { "imageUrl": "site/image3.png", "name": "name3" }, 
        { "imageUrl": "site/image4.png", "name": "name4" }, 
        ]
}

Then on the template

<div v-for="index in OBJs.length" :key="index">
    {{OBJs[index].imageUrl}}
</div>

But I keep getting this error.

enter image description here

If I render just the OBJs[index] like this:

<div v-for="index in OBJs.length" :key="index">
    {{OBJs[index]}}
</div>

...I get the all objects!

 { "imageUrl": "site/image1.png", "name": "name1" }
 { "imageUrl": "site/image2.png", "name": "name2" } 
 { "imageUrl": "site/image3.png", "name": "name3" } 
 { "imageUrl": "site/image4.png", "name": "name4" } 

so how come are they undefined? Anybody able to help?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you dont need to use length

just OBJs - then you will have item of array on each iteration

if you have structure like this:

export default {
    data() {
        return {
            data: {
                OBJs: [ 
                    { "imageUrl": "site/image1.png", "name": "name1" }, 
                    { "imageUrl": "site/image2.png", "name": "name2" }, 
                    { "imageUrl": "site/image3.png", "name": "name3" }, 
                    { "imageUrl": "site/image4.png", "name": "name4" }, 
                    ]
            }
        };
    }
};

UI:

<ul>
    <li v-for="item in data.OBJs" :key="item">{{item.imageUrl}}</li>
</ul>
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!