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?
Please consider this code example.
Vue watch child property
watch:{ 'item.someOtherProp'(newVal){ //to work with changes in "myArray" }, 'item.prop'(newVal){ //to work with changes in prop } }
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.