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 中多个组件的过渡动画</title>
  <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
  <style>
    .fade-enter,
    .fade-leave-to {
      opacity: 0;
    }
    .fade-enter-active,
    .fade-leave-active {
      transition: opacity 1s;
    }
  </style>
</head>
<body>
  <div id="app">
    <transition mode="out-in" name="fade">
      <child v-if="show"></child>
      <child-one v-else></child-one>
    </transition>
    <button @click="handleClick">切换</button>
  </div>
  <script>
    Vue.component('child',{
      template: '<div>child</div>'
    })
    Vue.component('child-one',{
      template: '<div>child-one</div>'
    })
    var vm = new Vue({
      el: "#app",
      data: {
        show: true
      },
      methods: {
        handleClick: function(){
          this.show = ! this.show
        }
      }
    })
  </script>
</body>
</html>
Output 300px

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

Dismiss x
public
Bin info
evenyaopro
0viewers