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

166
Vistas
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 Respuestas
Responde la pregunta

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 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