Vue3 路由页面切换动画 animate.css

animate.css官网

可以通过以下的内容,来获取自己想要的动态切换样式

在这里插入图片描述

1 路由动画transition或者在组件中控制使用animate

  • 安装
npm install animate.css
  • 在main.ts中引入
import 'animate.css/animate.min.css' //引入动画
  • 使用

在需要切换路由的页面中添加如下内容

html

<router-view v-slot="{ Component }">
   <transition name="router_animate">
     	<component :is="Component" />
   </transition>
</router-view>

css

.router_animate-enter-active {
    animation: slideInLeft 0.5s;
}
.router_animate-leave-active {
    animation: slideOutLeft 0.3s;
}

1.2 呈现结果

在这里插入图片描述

2 用于组件

控制类名是否加在元素上,值得注意的是,元素前面要加上animate__animated的前缀,下图:控制是否显示animate__bounce这个动画,flipinIntrue的时候

const flipinIn = ref(false); 
<el-button type="primary" @click=" flipinIn= true">animate.css实现</el-button>
<h1 class="animate__animated" :class="{animate__bounce:flipinIn}">动画文字</h1>

2.1 呈现结果

在这里插入图片描述

  • 3
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值