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

178
Vistas
Aggregate multiple objects as an array and synchronize changes

I start to use a third party <datetime-picker> component that only accept a Date[] of size 2 as its v-model (for a range of time). In my previous codebase, I maintained 2 separate Date objects, i.e. startTime and endTime, and I hope to stick with that.

// in previous codebase (class-based Vue component)
private startTime = new Date();
private endTime = new Date();

// now I must use an array due to the third-party component...
private dateTimeRange = [this.startTime, this.endTime];

Apparently the following won't work, since the reference itself in the array will be overwritten:

<datetime-picker v-model="dateTimeRange" ... />

I want a clean way to propagate changes (issued by the datetime picker component) to the array back to startTime and endTime object.

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

0

I would try it like this:

  1. private dateTimeRange = [new Date(), new Date()]; --> to remove the more complicated reference stuff through a "proxy" instance variable.

  2. Use a computed/property accessor to then receive and render both values:

    private get dateRange(): NiceType {
        return {start: this.dateTimeRange[0], end: this.dateTimeRange[0]}
    }
    
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