<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue中使用animate.css</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.5.2/animate.min.css">
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
</head>
<style>
/*@keyframes bounce-in {
0% {
transform: scale(0);
}
50% {
transform: scale(1.5);
}
100% {
transform: scale(1);
}
}
.fade-enter-active {
transform-origin: left center;
animation: bounce-in 1s;
}
.fade-leave-active {
transform-origin: left center;
animation: bounce-in 1s reverse;
}*/
div{
font-size: 20px;
width: 300px;
margin:200px auto;
}
</style>
<body>
<div id="app">
<transition name='fade'
enter-active-class='animated zoomOutLeft'
leave-active-class='animated zoomOutRight'>
<div v-if='show'>hello world</div>
</transition>
<button @click="handleClick">切换</button>
</div>
<script>
new Vue({
el: "#app",
data: {
show: true
},
methods: {
handleClick: function() {
this.show = !this.show;
}
}
})
</script>
</body>
</html>
使用animate.css必须使用vue的
enter-active-class
和leave-active-class
;后面紧跟animated
类名和想使用的动画名称(区分大小写) ,animate官网
网友评论