Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Vue中的JS动画与velocity.js</title>
  <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
</head>
<body>
  <div id="app">
    <transition
        name="fade"
        @before-enter="handleBeforeEnter"
        @enter="handleEnter"
        @after-enter="handleAfterEnter"
    >
      <div v-show="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
        },
        handleBeforeEnter: function(el){
          el.style.color = 'red'
        },
        handleEnter: function(el, done){
          setTimeout(() => {
            el.style.color = 'green'
          },2000)
          setTimeout(() => {
            done()
          },4000)
        },
        handleAfterEnter: function(el){
          el.style.color = "#000"
        }
      }
    })
  </script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
evenyaopro
0viewers