<style>
  @keyframes bounce-in {
    0% {
      transform: scale(0);
    }
    50% {
      transform: scale(1.5)
    }
    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>
<div id='app'>
  <transition name='fade'>
    <div v-if='show'>hello world</div>
  </transition>
  <button @click='handleClick'>切换</button>
</div> <script>
var vm = new Vue({
  el:'#app',
  data:{
    show:true
  },
  methods:{
    handleClick:function(){
      this.show = !this.show;
    }
  }
})
</script>

这是个放大的动画效果,在vue里面能不能不用fade-leave-active,fade-enter-active这样的规定好的class,我要用自定义的可不可以,可以

<style>
  .active{
    transform-origin: left center;
    animation: bounce-in 1s;
  }
  .leave{
    transform-origin: left center;
    animation: bounce-in 1s reverse;
  }
</style> <transition
  name='fade'
  enter-active-class='active'
  leave-active-class='leave'
>
  <div v-if='show'>hello world</div>
</transition>

在transition里面起自己的别名

既然可以自定义自己的class,就可以使用我们的animate.css库,animate.css库是
https://daneden.github.io/animate.css/
这个库提供了很多动画效果,我们如果要使用这个动画效果,可以下载下来
<script src="../vue.js"></script>
<link rel='stylesheet' type='text/css' href="../animate.css">
<div id='app'>
  <transition
    name='fade'
    enter-active-class='animated swing'
    leave-active-class='animated
shake'
  >
    <div v-if='show'>hello world</div>
  </transition>
  <button @click='handleClick'>切换</button>
</div> <script>
var vm = new Vue({
  el:'#app',
  data:{
    show:true
  },
  methods:{
    handleClick:function(){
      this.show = !this.show;
    }
  }
})
</script>
引入animate,出场动画,入场动画就不用自己写了,animated表示引入库里面的动画,后面的swing,shake表示要引入的具体动画名
 
用这个动画库的好处是很多复杂的效果就不用自己写了,直接用库里面的动画效果就可以实现
 

在vue中使用animate库的更多相关文章

  1. vue中使用animate.css

    一:使用animate.css的使用 1.安装npm install animate.css --save 2.在main.js中引入import animate from 'animate.css' ...

  2. vue中使用animate.css动画库

    1.安装: npm install animate.css --save 2.引入及使用: //main.js中 import animated from 'animate.css' Vue.use( ...

  3. 050——VUE中使用js库控制vue过渡动作

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 在vue中使用animate.css

    animate.css是一款前端动画库,相似的有velocity-animate 用法: 首先 npm install animate.css --save 然后在vue文件的script中引入: i ...

  5. 048——VUE中使用animate.css动画库控制vue.js过渡效果

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 010——VUE中使用lodash库减少watch对后台请求的压力

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. vue中使用animate.css实现动画

    参考链接:https://www.cnblogs.com/ccyinghua/p/7872694.html 参考链接:https://www.jianshu.com/p/2e0b2f8d40cf 使用 ...

  8. Vue 中的动画特效

    Vue 中的动画特效 CSS 实现标签显隐 <!DOCTYPE html> <html lang="en"> <head> <meta c ...

  9. vue中使用第三方插件animate.css实现动画效果

    vue中使用第三方插件animate.css实现动画效果1.首先先引入第三方类animated.css2.将你所需要动画的标签用包裹起来3.在transition元素中添加enter-active-c ...

随机推荐

  1. esper(4-1)-简单context

    1.创建context语法 create context context_name partition [by] event_property [and event_property [and ... ...

  2. js 实现继承的几种方式

    //js中实现继承的几种方式 //实现继承首先要有一个父类,先创造一个动物的父类 function Animal(name){ this.name = name; this.shoot = funct ...

  3. 01 性能优化基础怀实践 之 ASH分析

    1.模拟一个会话阻塞的场景.    通过update 同一行数据达到模拟阻塞的效果 : SQL> create table t1 (id number ,name varchar2(20)) ; ...

  4. 那些NPM文档中我看不懂地方

    $cookies.set(keyName, value[, expireTimes[, path[, domain[, secure]]]]) //return this 中括号代表可选参数 上面一行 ...

  5. 关系型数据库---MySQL---事务

    1.概述 1.1 事务:在对业务相关的一系列数据进行操作时,需要保证数据操作的完整性(要么全部成功.要么全部失败): 1.2 MySQL中支持事务的存储引擎是:Innodb: 1.3 事务用来管理in ...

  6. cesm1_2_2在南信大大型机上的移植以及运行简单case的步骤

    真实验证有效:点击链接 查看具体移植过程.

  7. python 列表学习

    一.创建一个列表(list)_使用逗号分隔不同的数据项,使用方括号括起来. list = [1,2,3,4,5,6,7] 与字符串的索引一样,列表索引从 0 开始,列表可以截取.组合. 二.访问列表中 ...

  8. https Android 5.0 以下TLS 版本过低造成的问题

    异常如下 javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ...

  9. Android Studio CMake依赖第三方库

    这里实现一个简单的功能在APP里调用libnative-lib.so里的add.libnative-lib.so去调用libthird.so里的third_add来实现 JniUtil public ...

  10. [转]创建一个JavaScript弹出DIV窗口层的效果

    本文转自:http://www.soso.io/article/23698.html <!doctype html> <html lang="en"> &l ...