当前位置:网站首页>Vue3 route cache component status and set transition animation
Vue3 route cache component status and set transition animation
2022-06-13 06:36:00 【Upwind elegance】
And vue2 Component state cache
<div id="app">
<keep-alive>
<router-view />
</keep-alive>
</div>
atypism .
vue3 Using the above component caching method will not take effect .
vue3 The component cache mode is :
<router-view v-slot="{ Component }">
<!-- <transition name="fade-transform"> -->
<keep-alive>
<component :is="Component" />
<!-- </keep-alive> -->
</transition>
</router-view>
Among them through transition You can set transition animation :
route.meta.transition Used to handle different routes using different animations
But we need to define the animation style such as route.meta.transition = aa Then define the style .aa-enter-active .aa-enter-from .aa-enter-to Wait for the pattern
route.meta.transition || 'fade' Route is not defined meta Attribute transition attribute Then use fade Animation All in all 6 Medium style
enter-active Route entry process Include enter-from enter-to
eave-active Route leaving process 、 Include leave-from leave-to The above two define animation effects The following definition The state of beginning and ending
enter-from Begin to enter
enter-to Enter complete
leave-from Start to leave
leave-to Leave complete
<template>
<router-view v-slot="{ Component }">
<transition name="fade-transform">
<!-- name="fade-transform" Name of the transition animation for the component -->
<keep-alive>
<component :is="Component" />
</keep-alive>
</transition>
</router-view>
<!-- <keep-alive>
<router-view></router-view>
</keep-alive> -->
</template>
<style>
.fade-transform-enter-active,
.fade-transform-leave-active {
transition: opacity 5s ease 0s;
}
.fade-transform-enter-from,
.fade-transform-leave-to {
opacity: 0;
}
.fade-transform-leave-from,
.fade-transform-enter-to {
opacity: 1;
}
</style>
The effect of transition animation :
Reference link :vue-router transition Simple switching effect - Rong Chao - Blog Garden
边栏推荐
- Analysis of 43 cases of MATLAB neural network: Chapter 10 classification of discrete Hopfield Neural Network -- evaluation of scientific research ability of colleges and Universities
- Error in downloading opencv from pip
- 'ipconfig' is not an internal or external command, nor is it a runnable program or batch file.
- App performance test: (I) startup time
- Kotlin collaboration channel
- Dragon Boat Festival wellbeing, use blessing words to generate word cloud
- Huawei developer certification and deveco studio compiler Download
- ADB shell CMD overlay debugging command facilitates viewing system framework character resource values
- Notifyitemchanged flash back
- [one · data 𞓜 simple implementation of the leading two-way circular linked list]
猜你喜欢
Construction and verification of Alibaba cloud server webrtc system
端午安康,使用祝福话语生成词云吧
SSM framework integration -- > simple background management
[FAQs for novices on the road] about technology management
JS to realize bidirectional data binding
El form form verification
Omron Ping replaces the large domestic product jy-v640 semiconductor wafer box reader
Two uses of bottomsheetbehavior
Free screen recording software captura download and installation
Super model logo online design and production tool
随机推荐
Recommend a capacity expansion tool to completely solve the problem of insufficient disk space in Disk C and other disks
【新手上路常见问答】一步一步理解程序设计
Wechat applet: use of global state variables
RN Metro packaging process and sentry code monitoring
Introduction to applet layout
【2022高考季】作为一个过来人想说的话
Wechat applet: click the event to obtain the current device information (basic)
Kotlin collaboration - simple use of collaboration
SSM integration
MFS details (VII) -- MFS client and web monitoring installation configuration
线程相关点
Logcat -b events and eventlogtags print the location correspondence of the events log in the code
时间格式化工具----moment.js(网页时间实时展示)
Recent problems
JetPack - - - DataBinding
Fidde breakpoint interception
‘ipconfig‘ 不是内部或外部命令,也不是可运行的程序 或批处理文件。
[written examination questions of meituan]
Comprehensive overview of ijkplayer contour features for ijkplayer code walk through
【sketchup 2021】草图大师中CAD文件的导入与建模(利用cad图纸在草图大师中建立立面模型)、草图大师导出成品为dwg格式的二维、三维、立面效果到cad中打开预览】