美文网首页
Vue中使用animate.css

Vue中使用animate.css

作者: daoqing99 | 来源:发表于2018-04-17 16:23 被阅读0次
    <!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官网

    相关文章

      网友评论

          本文标题:Vue中使用animate.css

          本文链接:https://www.haomeiwen.com/subject/ackpkftx.html