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

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

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 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!