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

105
Vistas
Vue 3: Flattening a reactive array of objects without destroying reactivity

When I try to flatten a Vue 3 reactive array of nested objects, I lose their reactivity and my app literally crashes and hangs the browser window.

My Vue 3 component defines an array as a list of objects:

this.grouped = [
          [this.tokens[0]],
          [this.tokens[1]],
          [this.tokens[2],this.tokens[3],this.tokens[4]], // nested
          [this.tokens[5]]
]

I need to take the the 2nd index (where the array nests 3 objects) and flatten it so that the resulting array looks like it would have been defined like this:

this.grouped = [
          [this.tokens[0]],
          [this.tokens[1]],
          [this.tokens[2]], //flattened
          [this.tokens[3]], //flattened
          [this.tokens[4]], //flattened
          [this.tokens[5]]
]

When I try to use splice to do this, the reactivity is lost (example below, showing the lost reactivity. Any ideas how to do it?

enter image description here

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

0

Try Array#flat:

const res = this.grouped.flat();
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