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

vue动画效果实现方法示例

程序员文章站 2023-12-04 22:25:10
本文实例讲述了vue动画效果实现方法。分享给大家供大家参考,具体如下: ...

本文实例讲述了vue动画效果实现方法。分享给大家供大家参考,具体如下:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>www.jb51.net vue动画</title>
  <script src="https://cdn.bootcss.com/vue/2.4.4/vue.min.js"></script>
  <link rel="stylesheet" href="https://cdn.bootcss.com/animate.css/2.0/animate.css" rel="external nofollow" />
  <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>

运行效果:

vue动画效果实现方法示例

感兴趣的朋友可以使用在线html/css/javascript代码运行工具http://tools.jb51.net/code/htmljsrun测试上述代码运行效果。

希望本文所述对大家vue.js程序设计有所帮助。