我正在为我的作品集使用 vue 和 vue-router。我添加了简单的“淡入淡出”动画。我的动画很滞后。
我的 App.vue 组件:
<template>
<div id="app">
<Square/>
<Navbar/>
</div>
</template>
我的 Square.vue 组件:
<template>
<div id="square">
<transition name="fade">
<router-view></router-view>
</transition>
</div>
</template>
<style>
.fade-enter-active, .fade-leave-active {
transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to{
opacity: 0;
}
</style>
我的路线文件:
import Vue from 'vue';
import Router from 'vue-router';
import Hello from './views/Hello.vue';
Vue.use(Router);
export default new Router({
routes: [
{
path: '/',
name: 'hello',
component: Hello,
},
{
path: '/i-am',
name: 'I am',
component: () => import(
'./views/About.vue'),
},
{
path: '/i-use',
name: 'I use',
component: () => import(
'./views/Using.vue'),
},
],
});
而且我认为这不是因为动画的风格。新内容呈现比旧组件销毁更快。
最佳答案
VueJS 过渡组件有一个很酷的 Prop ,叫做模式。 这将在销毁前一个组件时添加平滑效果。
<transition name="fade" mode="out-in">
<!-- ... the buttons ... -->
</transition>
https://v2.vuejs.org/v2/guide/transitions.html#Transition-Modes
关于javascript - 我的 vuejs 动画/过渡在路径更改方面滞后。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53330271/