Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

309
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda