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

315
Vistas
Vue - perform an action on just the newly added element in a v-for array

I have a v-for array that holds a bunch of elements. After the user performing certain actions, I insert another element at the front of the array.

I want the element to initially have a height of 0, and to slowly expand to a height of 150px. The other elements should remain 150px like they were before.

My failed attempt was to try to assign a class with height 0 to the the newly inserted element:

    <div id="brickHolder">
      <svg
        v-for="brick in bricks" :id="brick.id"
        class="expandable" :class="{not_expanded: keepShut(brick.id)}"
      </svg>
    </div>
    keepShut(id) {
      return id === this.bricks[0].id
    },

And to then remove it, triggering the expansion animation:

        let parent = document.getElementById("brickHolder");
        parent.children[0].classList.remove('not_expanded');

But that doesn't work. What's a better way?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

A good solution would be to use List Transitions i Vue.

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