Ashraam
413
2
Vue

Vue-router, transition on dynamic routes ?

Posted 2 years ago by Ashraam

Hi everyone,

I'm building a simple SPA and when I've got a transition on page change. But I've noticed a problem when I'm just updating the param in the url.

Example:

  • When I go from home -> users, there is my transition

  • When I go from users -> user/1, there is the transition

  • When I go from user/1 -> user/2, there is NO transition (at the beginning the component wasn't even updated.)

To update the component when I change the parameter in the url I have to watch for this param like

watch: {
        '$route' (to, from) {
            this.fetchHero(to.params.id);
        }
    }

Is there a when to apply my transition to this watcher ?

Thanks

Please sign in or create an account to participate in this conversation.