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

Animate.css库使用

程序员文章站 2024-03-25 13:04:04
...
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态组件</title>
    <script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
    <style>
        /* 使用keyframe形式的动画 */
        @keyframes bounce-in{
            0% {
                transform: scale(0);
            }
            50% {
                transform: scale(1.2)
            }
            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;
        }
    </style>
</head>
<body>
    <!-- 
        
     -->
    <div id="app">
        <transition name="fade">
                <div v-show="show">hello world</div>
        </transition>
        <button @click="handleChange">显示与隐藏</button>
    </div>
    <script>
       
        var vm = new Vue({
            el : "#app",
            data : {
                show : true
            },
            methods : {
                handleChange : function(){
                    this.show = !this.show
                }
            }
        })
    </script>
</body>
</html>