https://segmentfault.com/a/1190000018125564 很完善了,重點是兩個過程圖。
<style> .fade-enter{ opacity: 0; } .fade-enter-active{ transition: opacity 3s; } /* .fade-enter-to{ color: red; } .fade-leave{ color: green; } */ .fade-leave-to{ opacity: 0; } .fade-leave-active{ transition: opacity 3s; } </style> </head> <body> <!-- 過程如下: 顯示 fade-enter,fade-enter-active fade-enter-active,fade-enter-to 空 隱藏 fade-leave,fade-leave-active fade-leave-active,fade-leave-to 空 --> <div id="root"> <transition name='fade'> <h1 v-show='show'> 最是年少時模樣 </h1> </transition> <button @click='change'>切換</button> </div> <script> var vm=new Vue({ el:'#root', data:{ show:true }, methods:{ change:function(){ this.show=!this.show; } } }) </script> </body>