1.如何使用animate框架
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue中css动画的原理</title>
<script src="script/vue.js"></script>
<link rel="stylesheet" href="style/animate.css" />
</head>
<body>
<div id="root">
<transition
enter-active-class="animated tada" //必须要用自定义类这样的写法,这句话的意思是enter-active这个类重新定义为括号内的值;这里animated注意这里过了个d 后面的加上需要的动态
leave-active-class="animated flash">
<div v-if="show">hello world</div>
</transition>
<button @click="click">切换</button>
</div>
<script>
var root = new Vue({
el : '#root',
data:{
show:true
},
methods:{
click:function(){
this.show = !this.show;
}
}
})
</script>
</body>
</html>
当@keyframes和animate.css框架一起使用是时候
<div id="root">
<!-- appear刚刚刷新成功 -->
<!--有使用过渡又使用@keyframes中的animate.css框架-->
<!--type="transition"规定时间选择为transition设置的时间为主-->
<!--把type="transition"设置为:duration="10000"在经过10S后动画执行完-->
<!--:duration={enter:5000,eaver:10000}设置出场和入场-->
<transition
type="transition"
name="fade"
appear
enter-active-class="animated swing fade-enter-active"
leave-active-class="animated shake fade-leave-active"
appear-active-class="animated swing">
<div v-if="show">hello world</div>
</transition>
<button @click="click">切换</button>
</div>
<script>
var root = new Vue({
el : '#root',
data:{
show:true
},
methods:{
click:function(){
this.show = !this.show;
}
}
})
</script>