Vue-router: How to use transition when router matched?

Created on 13 Apr 2016  ·  6Comments  ·  Source: vuejs/vue-router

I can't write transition on router-view like <router-view transition ="fade">`

so, how to use transition on this case?

Most helpful comment

Transitions are supported in <router-view></router-view>. This is a working example from my code:
<router-view transition="fade" transition-mode="out-in" class="animated"></router-view> using Animate.css and my transition registered as this:
Vue.transition('fade', { enterClass: 'fadeIn', leaveClass: 'fadeOut'})
It's also stated in the documentation: http://vuejs.github.io/vue-router/en/view.html

All 6 comments

Transitions are supported in <router-view></router-view>. This is a working example from my code:
<router-view transition="fade" transition-mode="out-in" class="animated"></router-view> using Animate.css and my transition registered as this:
Vue.transition('fade', { enterClass: 'fadeIn', leaveClass: 'fadeOut'})
It's also stated in the documentation: http://vuejs.github.io/vue-router/en/view.html

Thank you sagaio!
And I found the router configuration "transitionOnLoad" for this case

Where should I put this line?

Vue.transition('fade', { enterClass: 'fadeIn', leaveClass: 'fadeOut'})

I want the transition for all of my routes.

@Wipsly just in the main.js, if you create the project by vue-cli.

Closing since the issue is resolved.

very nice!

Was this page helpful?
0 / 5 - 0 ratings