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

250
Vistas
How to watch object in vue js?

I have object with longitude and latitude?

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

}

I am trying to watch it like this but not working

 watch:{
    "center2.lat":function (newValue, oldValue) {
     
      this.center2.lat = newValue;
    }
    , "center2.lng":function (newValue, oldValue) {
     
      this.center2.lng = newValue;
    }
    },

How I could do it?

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

0

Please consider this code example.

  1. Vue watch child property

    watch:{ 'item.someOtherProp'(newVal){ //to work with changes in "myArray" }, 'item.prop'(newVal){ //to work with changes in prop } }

  2. Vue watch object member

    watch: { item: { handler(val){ // do stuff }, deep: true } }

Also please consider this reference.https://vuejs.org/v2/api/#watch. You can deeply watch objects for changes.

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