index.vue 959 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <script>
  2. import './index.css'
  3. export default {
  4. // #ifdef H5
  5. onLaunch: function() {
  6. this.show()
  7. this.$router.beforeEach((to, from, next) => {
  8. this.hide(next)
  9. })
  10. this.$router.afterEach(() => {
  11. setTimeout(this.show, 50)
  12. })
  13. },
  14. methods: {
  15. hide(callback) {
  16. const classList = document.querySelector('uni-page').classList
  17. classList.add('animation-before', 'animation-leave')
  18. classList.remove('animation-show')
  19. setTimeout(() => {
  20. classList.remove('animation-before', 'animation-leave')
  21. callback && callback()
  22. }, 300)
  23. },
  24. show() {
  25. const classList = document.querySelector('uni-page').classList
  26. classList.add('animation-before')
  27. setTimeout(() => {
  28. classList.add('animation-enter', 'animation-after', 'animation-show')
  29. setTimeout(() => {
  30. classList.remove('animation-before', 'animation-after', 'animation-enter')
  31. }, 300)
  32. }, 20)
  33. }
  34. },
  35. // #endif
  36. }
  37. </script>