Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Vue 3: aplanar una matriz reactiva de objetos sin destruir la reactividad

Cuando trato de aplanar una matriz reactiva Vue 3 de objetos anidados, pierdo su reactividad y mi aplicación literalmente falla y bloquea la ventana del navegador.

El componente My Vue 3 define una matriz como una lista de objetos:

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

Necesito tomar el segundo índice (donde la matriz anida 3 objetos) y aplanarlo para que la matriz resultante se vea como si se hubiera definido así:

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

Cuando trato de usar el splice para hacer esto, se pierde la reactividad (ejemplo a continuación, que muestra la reactividad perdida. ¿Alguna idea de cómo hacerlo?

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prueba Array#flat :

 const res = this.grouped.flat();
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!