简体   繁体   中英

Vue.js component only updating after browser page refresh

So I am still quite new to Vue.js or any reactive framework for that matter.

I have a component that I need to have update whenever a change is made. The idea is that it is taking a balance from a specific login.

<li :key="balance">Balance {{ balance }}</li>
data() {
    return {
      games: [],
      balance: '101',
      error: ''
    }
}

async created() {
    try{
      this.balance = await WalletService.getBalance();
    } catch(err){
      console.log(err.message);
    }
  }

From my own debugging, it looks like the created() function is not being called after my router.push() when the user logs in. How can I ensure that created() is called after router.push

Remove the async keyword from created() .

Although lifecycle methods can perform asynchronous code, the lifecycle itself is synchronous.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM