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

127
Vistas
convert similar computed properties to use just one

I have those 3 computed properties is it possible to make them in just one ?

    first() {
      const mydate1 = new Date();
      mydate1.setDate(mydate1.getDate() + 1);
      return mydate1;
    },
    second() {
      const mydate2 = new Date();
      mydate2.setDate(mydate2.getDate() + 2);
      return mydate2;
    },
    third() {
      const mydate3 = new Date();
      mydate3.setDate(mydate3.getDate() + 3);
      return mydate3;
    },    

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

This is perfectly okay for a computed property...

dates() {
  const baseDate = new Date().getDate();

  const first = new Date();
  first.setDate(baseDate + 1);

  const second = new Date();
  second.setDate(baseDate + 2);

  const third = new Date();
  third.setDate(baseDate + 3);

  return { first, second, third };
},    

Previous references to, say, second, can change to dates.second. Same for all three.

over 4 years ago · Santiago Trujillo Denunciar

0

Instead of using computed properties, why not make a method getDate(offset) that returns a new Date?

methods: {
  getDate(offset) {
    const myDate = new Date();
    myDate.setDate(myDate.getDate() + offset);
    return myDate;
  }
}
over 4 years ago · Santiago Trujillo 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