transition.html 988 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <title></title>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <script src="https://unpkg.com/vue/dist/vue.js"></script>
  8. <link href="../css/style.css" rel="stylesheet"> </head>
  9. <body>
  10. <div id="myApp">
  11. <!-- 简单元素 -->
  12. <transition>
  13. <div v-if="ok">toggled content</div>
  14. </transition>
  15. <!-- 动态组件 -->
  16. <transition name="fade" mode="out-in" appear>
  17. <component :is="view"></component>
  18. </transition>
  19. <!-- 事件钩子 -->
  20. <div id="transition-demo">
  21. <transition @after-enter="transitionComplete">
  22. <div v-show="ok">toggled content</div>
  23. </transition>
  24. </div>
  25. </div>
  26. <script>
  27. var myApp = new Vue({
  28. el: '#myApp',
  29. data: {
  30. },
  31. methods: {
  32. transitionComplete: function(el) {
  33. // 传入 'el' 这个 DOM 元素作为参数。
  34. }
  35. }
  36. });
  37. myApp.$mount('#transition-demo')
  38. </script>
  39. </body>
  40. </html>