App.vue 952 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div id="app">
  3. <button @click="show = !show">切换</button>
  4. <transition name="move">
  5. <MyTransition v-show="show" />
  6. </transition>
  7. </div>
  8. </template>
  9. <script>
  10. import MyTransition from './components/MyTransition.vue';
  11. export default {
  12. name: 'App',
  13. data() {
  14. return {
  15. show: true,
  16. };
  17. },
  18. components: {
  19. MyTransition,
  20. },
  21. };
  22. </script>
  23. <style>
  24. #app {
  25. font-family: Avenir, Helvetica, Arial, sans-serif;
  26. -webkit-font-smoothing: antialiased;
  27. -moz-osx-font-smoothing: grayscale;
  28. text-align: center;
  29. color: #2c3e50;
  30. margin-top: 60px;
  31. }
  32. .move-enter-active {
  33. animation: move-frame 0.5s linear;
  34. }
  35. .move-leave-active {
  36. animation: move-frame 0.5s linear reverse;
  37. }
  38. @keyframes move-frame {
  39. 0% {
  40. transform: translateY(-100px);
  41. opacity: 0;
  42. }
  43. 50% {
  44. transform: translateY(-20px);
  45. opacity: 0.5;
  46. }
  47. 100% {
  48. transform: translateY(0px);
  49. opacity: 1;
  50. }
  51. }
  52. </style>