Commit 86ef24e8 authored by 何远江's avatar 何远江

添加路由切换过度效果

parent 967b0d25
<template>
<RouterView>
<template #default="{ Component, route }">
<Transition name="Child" mode="out-in" appear>
<div :key="route.fullPath">
<transition name="fade-slide" mode="out-in" appear>
<div :key="route.path">
<keep-alive v-if="route.meta?.keepAlive">
<component :is="Component" :key="route.fullPath"></component>
<component :is="Component" :key="route.path"></component>
</keep-alive>
<component v-else :is="Component" :key="route.fullPath"></component>
<component v-else :is="Component" :key="route.path"></component>
</div>
</Transition>
</transition>
</template>
</RouterView>
</template>
<script lang="ts" setup></script>
<style></style>
<style scoped>
.fade-slide-leave-active,
.fade-slide-enter-active {
transition: all 0.3s;
}
.fade-slide-enter-from {
transform: translateX(-30px);
opacity: 0;
}
.fade-slide-leave-to {
transform: translateX(30px);
opacity: 0;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment