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">
<!-- 必须要用自定义类这样的写法,这句话的意思是enter-active这个类重新定义为括号内的值 -->
<transition enter-active-class="animated tada" 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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)