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

165
Views
How to dynamically add attributes in vue.js components

I am making a news website using NYT REST API. I want to add attributes to the components dynamically using the document.getElementsByClassName()

For Example, I want to add a title to my component (the title is a prop actually of type String), I want to add it dynamically using a loop. I have added it normally in the given code snippet, but what if I have 30 components and I have data in an array and I want to give title from that array.

<News_Card class="card" :title='this.all_data[0].title' />

I want this :title='this.all_data[0].title to be added using loop

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

0

You could use v-for directive to render the all_data items :

<News_Card class="card" v-for="(item,index) in all_data" 
                    :title='item.title' :key="index" />
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!