You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.4 KiB

8 months ago
  1. <!-- 加载动画页面 -->
  2. <template>
  3. <view v-if="loading" class="loading">
  4. <div class="loader"></div>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. num : 4, //默认2秒后关闭(这里处理初始页面重叠的bug,初始页面是2秒后消失,所以这里加个2)
  12. interval : null
  13. }
  14. },
  15. created(){
  16. this.interval = setInterval(() => {
  17. if(this.num <= 0){
  18. this.num = 4;
  19. this.$emit('close');
  20. clearInterval(this.interval)
  21. }
  22. this.num--;
  23. },1000)
  24. },
  25. destroyed(){
  26. if(this.interval){
  27. clearInterval(this.interval)
  28. }
  29. },
  30. props : {
  31. loading : {
  32. type : Boolean,
  33. default : true
  34. }
  35. },
  36. methods: {
  37. }
  38. }
  39. </script>
  40. <style lang="scss" scoped>
  41. .loading {
  42. display: flex;
  43. justify-content: center;
  44. .loader {
  45. width: 50px;
  46. aspect-ratio: 1;
  47. display: grid;
  48. }
  49. .loader::before,
  50. .loader::after {
  51. content: "";
  52. grid-area: 1/1;
  53. --c: no-repeat radial-gradient(farthest-side, #B0C73B 92%, #0000);
  54. background:
  55. var(--c) 50% 0,
  56. var(--c) 50% 100%,
  57. var(--c) 100% 50%,
  58. var(--c) 0 50%;
  59. background-size: 12px 12px;
  60. animation: l12 1s infinite;
  61. }
  62. .loader::before {
  63. margin: 4px;
  64. filter: hue-rotate(45deg);
  65. background-size: 8px 8px;
  66. animation-timing-function: linear
  67. }
  68. @keyframes l12 {
  69. 100% {
  70. transform: rotate(.5turn)
  71. }
  72. }
  73. }
  74. </style>