[Vuejs]-Vuejs conditionally render nav items after authentication

0👍

Use a getter for it, beforeCreate doesn’t matter here because the elements aren’t available anyway, so using a getter makes the most sense as it will fire only when the component is available:

computed: {
  showNav() {
    return User.checkAuth()
  }
}

0👍

Alright, figured this out by calling window.location = '/' in my User.js login method, rather than this.$router.replace('/') in the login component’s login method. Timing is everything.

Leave a comment