Animate.css在vue中的使用

Animate.ss的动画效果超可爱的,用起来也方便,最近用了,记录一下

? vue中animate.css的安装和使用

安装:

npm install animate.css --save
//或者
yarn add animate.css

使用

? 在入口文件中引入

import animate from 'animate.css'
Vue.use(animate)

? 选择你要的样式

打开官网Animate.css
在这里插入图片描述
? 具体使用
在你需要动画样式的地方把样式名称写上就行
注意!一定要写这个animated
在这里插入图片描述
? animate.css在vue中的入场和离场动画
enter-active-class和leave-active-class在vue官网中有介绍
点击,vue官网走一波

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>动画-未使用动画</title>
		<link rel="stylesheet" href="css/animate.css" />
		<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
		<style>
			.demo{
				width: 150px;
				height: 150px;
				background-color: pink;
			}
		</style>
	</head>
	<body>
		<!--点击按钮让h3显示,再点击,让h3显示-->	
		<div id="example">
			<input type="button" value="btn" @click="flag=!flag"/>			
			<!--使用transtion元素把需要被动画控制的元素包裹起来-->
			<!--transition元素是官方提供的--> 
			<!--使用animate.css库-->
			<transition enter-active-class="animated bounceIn" leave-active-class="animated bounceOut" :duration="400"><!--入场和离场的时间-->
				<div v-if="flag" class="demo">
					<span>animate.css的动画效果实现</span>
				</div>
			</transition>			
		</div>
		<script>
			var vm=new Vue({
				el:'#example',
				data:{
					flag:false
				}
			})
		</script>
	</body>
</html>

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值