¿Tengo un objeto con longitud y latitud?
data(){ return{ center2:{lat:0,lng:0} } }Estoy tratando de verlo así pero no funciona.
watch:{ "center2.lat":function (newValue, oldValue) { this.center2.lat = newValue; } , "center2.lng":function (newValue, oldValue) { this.center2.lng = newValue; } },¿Cómo podría hacerlo?
Considere este ejemplo de código.
Propiedad secundaria de Vue Watch
watch:{ 'item.someOtherProp'(newVal){ //para trabajar con cambios en "myArray" }, 'item.prop'(newVal){ //para trabajar con cambios en prop } }
Miembro del objeto Vue Watch
ver: { item: { handler(val){ // hacer cosas }, deep: true } }
También considere esta referencia. https://vuejs.org/v2/api/#watch. Puede observar profundamente los objetos en busca de cambios.