Vue的JavaScript钩子

JavaScript钩子

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>javascript钩子(使用Velocity)</title>
    <script src="https://unpkg.com/vue"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.min.js"></script>
</head>
<body>
    <div id = "demo">
          <button @click = "show = !show">click me</button>
          <transition 
            v-on:before-enter="beforeEnter"
            v-on:enter="enter"
            v-on:leave="leave"
            v-bind:css="false"
          >
              <p v-if="show">ling</p>
          </transition>
          
    </div>

    <script>
         var vm = new Vue({
             el:'#demo',
             data:{
                 show:false
             },
             methods:{
                beforeEnter: function (el) {
                    el.style.opacity = 0;
                    el.style.transformOrigin = 'left'
                },
                enter: function (el, done) {
                    Velocity(el, { opacity: 1, fontSize: '3em' }, { duration: 300 })
                    Velocity(el, { fontSize: '1em' }, { complete: done })
               
                },

                leave: function (el, done) {
                    Velocity(el, { translateX: '15px', rotateZ: '50deg' }, { duration: 600 })
                    Velocity(el, { rotateZ: '100deg' }, { loop: 2 })
                    Velocity(el, {
                        rotateZ: '45deg',
                        translateY: '100px',
                        translateX: '100px',
                        opacity: 0
                    }, { complete: done })
                }
             }
         })


    </script>
</body>
</html>

效果图

在这里插入图片描述
参考文档
Vue.js文档
Velocity.js 中文文档

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值