Test.vue 873 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <div>
  3. <button @click="isShow = !isShow">显示/隐藏</button>
  4. <transition name="hello" appear>
  5. <h1 v-show="isShow">你好啊!</h1>
  6. </transition>
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. name:'Test',
  12. data(){
  13. return{
  14. isShow:true
  15. }
  16. }
  17. }
  18. </script>
  19. <style scoped>
  20. h1{
  21. background-color: orange;
  22. }
  23. /* .v-enter-active{
  24. animation: atguigu 1s linear;
  25. }
  26. .v-leave-active{
  27. animation: atguigu 1s linear reverse;
  28. } */
  29. .hello-enter-active{
  30. animation: atguigu 0.5s linear;
  31. }
  32. .hello-leave-active{
  33. animation: atguigu 0.5s linear reverse;
  34. }
  35. @keyframes atguigu{
  36. from{
  37. transform: translateX(-100%);
  38. }
  39. to{
  40. transform: translateX(0px);
  41. }
  42. }
  43. </style>