• vue的transition-group 下面每个元素分别执行动画


    vue中可以使用<transition-group> 组件同时渲染整个列表,对一组列表进行动画渲染,而当使用动态数据进行动画渲染时,我们可以使用钩子函数,那么如果我们要对每个元素分别执行动画,该怎么做呢?

      此时我们可以在列表标签中使用 v-bind:data-XXX="动态值",那么在钩子函数中就可以通过el.dataset.XXX拿到该值,从而分别执行动画!

    例如:

        <transition-group v-on:before-enter="beforeEnter" v-on:enter="enter">
             <span v-for="(item,index) in arr"  v-bind:key="item"  v-bind:data-index="item"> </span>
        </transition-group>
     
    <script>
      export default {
         methods:{
              beforeEnter: function (el) {
              },
             enter: function (el, done) {
                var index = el.dataset.index
                setTimeout(function () {
                   Velocity(
                      el,
                      { 'background-position-y':-100*index+'%' },
                      { duration: 5000 + index * -100,
                        easing: "easeInOutCirc",
                        complete: done }
                  )
                }, index * -10)
            },
          }
       }
    </script>
  • 相关阅读:
    【转】PHP操作MongoDB【NoSQL】
    web前端响应式
    CSS Hack
    ES6特性
    zepto.js使用前注意
    移动端 isScroll自定义实现
    严格模式use strict
    node.js和express.js安装和使用步骤 [windows]
    JSONP理解和使用
    require.js+backbone.js基本使用
  • 原文地址:https://www.cnblogs.com/sunala/p/8885681.html
Copyright © 2020-2023  润新知