I want to create a simple fade transition for my Vue routes and followed the docs from here. Somehow the animations never play but the new content appears immediately. I tried to reproduce it with a fresh project:
- Create a Vue2 project using the Vue router package with the Vue CLI
- Modify the App.vue file to
.
<template>
<div id="app">
<div>
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<transition name="fade">
<router-view :key="$route.path" />
</transition>
</div>
</template>
<style scoped>
.fade-enter-active,
.fade-leave-active {
transition: opacity 2s;
}
.fade-enter,
.fade-leave-to {
transition: opacity 0;
}
</style>
- run the app
- navigate by clicking the links in the navbar
This is a screenshot after clicking on the "About" route in the navbar
As you can see the content from the "Home" route does not fade out. It just disappears immediately after 2 seconds (value in CSS class). And the content from the "About" route does not fade in, it just appears immediately.
What am I missing?
I tried to create a reproducable fiddle to play around with
https://jsfiddle.net/jwuyathp/2/
Navigate around and you will see there is no fade animation.