码迷,mamicode.com
首页 > 其他好文 > 详细

vue-动画

时间:2017-08-24 01:06:06      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:ase   vue   utf-8   lan   inpu   ted   this   har   height   

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-动画

标签:ase   vue   utf-8   lan   inpu   ted   this   har   height   

原文地址:http://www.cnblogs.com/lanlanJser/p/7420921.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!