vue过渡

常用自定义动画

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

外部引用animation

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

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

推荐阅读更多精彩内容

  • 概述 Vue 在插入、更新或者移除 DOM 时,提供多种不同方式的应用过渡效果。包括以下工具: 在 CSS 过渡和...
    寒梁沐月阅读 1,409评论 0 3
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,827评论 25 709
  • 为了在vue里做个轮播图,找遍了网页博客,终于找到一个看的懂得文章具体轮播图的做法参考原文地址:点击这里 vue过...
    竹小星阅读 2,232评论 0 1
  • 一:word and expression 1.about secret Spell the secret/kno...
    z张文阅读 260评论 0 0
  • 生活,最有乐趣是自我突破。学习,成长,从0到1。凡是能使自己感到充实的,都应该被坚持,被鼓励。 今天让我玩一天,都...
    彭素娜nana阅读 158评论 0 0