Vue中使用animate.css
程序员文章站
2022-06-06 23:39:21
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vue中使用animate.css</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/animate.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/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官网