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

186
Vistas
vue change div from component

html:

    <div class='wrapper'>
      <div class='custom'>
        <div class='item'> 1</div>
        <div class='item'> 2 </div>
        <div class='item'> 3 </div>
      </div>
      <component-vue />
    </div>

Vue:

    methods: {
      doSomething() {
       document.querySelector('.custom).innerHTML = /new items
     }
    }

My question is, is this the only way to change the external div? I need to change items, new ones come from api. Maybe there is another way? If only through innerHTML, then how can I implement the idea?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

For example,

<div class="item" v-for="(item, index) in items" :key="index"></div>
data() {
   return {
      items: []
   }
},
methods: {
    doSomething() {
       // Fetch data from api and load
       this.items = res.data
   }
}

EDIT

<div class='custom' v-html="dataHtml"></div>
data() {
   return {
      dataHtml: `
      <div>Initial html</div>
      `
   }
},
methods: {
    doSomething() {
       // Fetch data from api and load
       this.dataHtml = createHtml(res.data) // Fictional method to parse data and transform to html f.e.
   }
}
over 4 years ago · Santiago Trujillo 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