Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!