• 在vue中同时使用过渡和动画


    在上次的动画中,在显示和隐藏有动画效果,但是,刷新页面的时候,第一次的显示没有动画效果
    需求:刷新页面的时候也有动画效果
    <transition
      name='fade'
      appear
      enter-active-class='animated swing'
      leave-active-class='animated shake'
      appear-active-class='animated swing'
    >
      <div v-if='show'>hello world</div>
    </transition>
    在transition里面加一个标签,appear,指定要使用appear,appear-active-class='animated swing'指定第一次出现的时候跟显示的时候效果一样
    需求:在执行动画的时候,加一个过渡效果,怎么弄
    将过渡动画也加上去
    <style>
      .fade-enter,.fade-leave-to{
        opacity: 0;
      }
      .fade-enter-active,.fade-leave-active{
        transition: opacity 5s;
      }
    </style>
    <div id='app'>
      <transition
        name='fade'
        appear
        enter-active-class='animated swing fade-enter-active'
        leave-active-class='animated shake fade-leave-active'
        appear-active-class='animated swing'
      >
        <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的时长,还是transition的时长,要整体使用transition的时长怎么做
    <transition
      name='fade'
      appear
      type='transition'
      enter-active-class='animated swing fade-enter-active'
      leave-active-class='animated shake fade-leave-active'
      appear-active-class='animated swing'
    >
      <div v-if='show'>hello world</div>
    </transition>
    在transition里面加个type属性,指定为transition,就可以
    自定义时长
    <transition
      :duration='{enter:5000,leave:10000}'
      name='fade'
      appear
      enter-active-class='animated swing fade-enter-active'
      leave-active-class='animated shake fade-leave-active'
      appear-active-class='animated swing'
    >
      <div v-if='show'>hello world</div>
    </transition>
    duration这个属性可自定义时长
  • 相关阅读:
    随题而学(二)多维数组转一维数组
    随题而学(一)
    谁能破解“无法定位程序输入点ucrtbase.abort与动态链接库api-ms-win-crt-runtime-l1-1-0.dll上”
    虚拟机8—tools安装失败
    win7介绍
    win xp安装
    Linux正则表达式,grep总结,sed用法
    Linux将用户添加到组的指令
    xxx is not in the sudoers file.This incident will be reported.的解决方法
    69-70连接查询
  • 原文地址:https://www.cnblogs.com/wzndkj/p/9689336.html
Copyright © 2020-2023  润新知