1. 程式人生 > >vue-動畫

vue-動畫

min height 按鈕 span wid tle scrip city cti

1

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="bower_components/vue/dist/vue.js"></script>
    <style>
        #div1{
            width:100px;
            height:100px;
            background
: red; } .fade-transition{ transition: 1s all ease; } .fade-enter{ opacity: 0; } .fade-leave{ opacity: 0; transform: translateX(200px); } </style> </head> <body> <div id
="box"> <input type="button" value="按鈕" @click="toggle"> <div id="div1" v-show="bSign" transition="fade"></div> </div> <script> new Vue({ el:#box, data:{ bSign:true }, methods:{
/*toggle:function(){ alert(1); }*/ toggle(){ this.bSign=!this.bSign; } } }); </script> </body> </html>

2

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="bower_components/vue/dist/vue.js"></script>
    <link rel="stylesheet" href="bower_components/animate.css/animate.css">
    <style>
        #box{
            width:400px;
            margin: 0 auto;
        }
        #div1{
            width:100px;
            height:100px;
            background: red;
        }
    </style>
</head>
<body>
    <div id="box">
        <input type="button" value="按鈕" @click="toggle">
        <div id="div1" class="animated" v-show="bSign" transition="bounce"></div>
    </div>

    <script>
        new Vue({
            el:#box,
            data:{
                bSign:true
            },
            methods:{
                toggle(){
                    this.bSign=!this.bSign;
                }
            },
            transitions:{ //定義所有動畫名稱
                bounce:{
                    enterClass:zoomInLeft,
                    leaveClass:zoomOutRight
                }
            }
        });
    </script>
</body>
</html>

3動態組件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="bower_components/vue/dist/vue.js"></script>
    <style>
    </style>
</head>
<body>
    <div id="box">
        <input type="button" @click="a=‘aaa‘" value="aaa組件">
        <input type="button" @click="a=‘bbb‘" value="bbb組件">
        <component :is="a"></component>
    </div>

    <script>
        var vm=new Vue({
            el:#box,
            data:{
                a:aaa
            },
            components:{
                aaa:{
                    template:<h2>我是aaa組件</h2>
                },
                bbb:{
                    template:<h2>我是bbb組件</h2>
                }
            }
        });

    </script>
</body>
</html>

vue-動畫