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

152
Vistas
Why vue compnent property doesn;t update When open it secodnd time?

I have vue component which data() property center2 which basicallly lng,lat object. This property supposes to update when every location changes. but it get updated for the very first time when I open the component. for every next attempt it only shows default values I have assigned.

data property

data()
{
return {
     center2: { lat: 0, lng: 0 },
}
}

This is how updating it with location inside location watcher

  this.center2.lat = Number(location.latitude);
       this.center2.lng = Number(location.longitude);
       console.log('MY',this.center2);

I can see in console lat long are coming nicely

What is the reason?

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

0

In Vue2, you might want to try returning center2 inside data(). It looks like below:

data() {
  return {
    center2: {
      lat: 0,
      lng: 0
    }
  }
}

Then center2 should be updated normally along with the watcher.

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