Vue动画--同时使用过渡和动画

code:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Vue中同时使用过渡和动画</title>
		<script type="text/javascript" src="js/vue.js" ></script>
		<link rel="stylesheet" href="css/animate.css" />
		<style>
			.fade-enter,.fade-leave-to{
				opacity: 0;
			}
			.fade-enter-active,.fade-leave-active{
				transition: opacity 3s;
			}
		</style>
	</head>
	<body>
		<div id="root">
			<!--appear 自定义-->
			<!--appear 定义刷新页面的动画-->
			<!--:duration="5000" 自定义时间长短,直接写时间-->			
			<transition 
				:duration="{enter:5000,leave:3000}"
				name="fade"
				enter-active-class="animated swing fade-enter-active"
				leave-active-class="animated shake fade-leave-active"
				appear
				appear-active-class="animated swing"
				>
				<div v-if="show">hello world</div>
			</transition>
			<button @click="handleClick">切换</button>
		</div>
		<script>
			new Vue({
				el:"#root",
				data:{
					show:true
				},
				methods:{
					handleClick(){
						this.show=!this.show
					}
				}
			})
		</script>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/AsaZyf/article/details/83759080