欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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-classleave-active-class;后面紧跟animated类名和想使用的动画名称(区分大小写) ,animate官网