Vue中使用animate.css

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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容