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

138
Views
Wait when variable change status in Vue

How I can run some code when my variable change.

for exaple: $store.state.AppStatus have status "busy" when vue component loaded then he change to "ready"

so i need run boostrap function on tab after $store.state.AppStatus change to "ready"

Now i use setTimeout couse its work but its not perfect...

My code mounted hook:

  mounted() {
    
    if (window.location.hash) {
      console.log(this.$store.state.AppStatus)
       setTimeout(() => {
            $(`a[href="${window.location.hash}"]`).tab('show')
          }, 1000);
      
    }  
  },
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use a Vue Watcher - https://vuejs.org/v2/guide/computed.html#Watchers

While computed properties are more appropriate in most cases, there are times when a custom watcher is necessary. That’s why Vue provides a more generic way to react to data changes through the watch option. This is most useful when you want to perform asynchronous or expensive operations in response to changing data.

watch: {
  '$store.state.AppStatus': function() {
    $(`a[href="${window.location.hash}"]`).tab('show')
  }
}
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!