index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="skeleton-box">
  3. <view v-if="loading" class="skeleton">
  4. <div class="spinner">
  5. <div class="spinner-container container1">
  6. <div class="circle1"></div>
  7. <div class="circle2"></div>
  8. <div class="circle3"></div>
  9. <div class="circle4"></div>
  10. </div>
  11. <div class="spinner-container container2">
  12. <div class="circle1"></div>
  13. <div class="circle2"></div>
  14. <div class="circle3"></div>
  15. <div class="circle4"></div>
  16. </div>
  17. <div class="spinner-container container3">
  18. <div class="circle1"></div>
  19. <div class="circle2"></div>
  20. <div class="circle3"></div>
  21. <div class="circle4"></div>
  22. </div>
  23. </div>
  24. </view>
  25. <van-transition v-else-if="list.length==0" name="fade-up">
  26. <view class="skeleton">
  27. 暂时没有数据
  28. </view>
  29. </van-transition>
  30. <van-transition v-else name="fade-up">
  31. <slot></slot>
  32. </van-transition>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. props: {
  38. loading: {
  39. type: Boolean,
  40. default: true
  41. },
  42. list: {
  43. type: Array,
  44. default: [1]
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .skeleton {
  51. display: flex;
  52. justify-content: center;
  53. align-items: center;
  54. padding: 50rpx;
  55. height: 320rpx;
  56. }
  57. .led {
  58. width: 10rpx;
  59. height: 30rpx;
  60. border-radius: 10rpx;
  61. top: 50rpx;
  62. position: absolute;
  63. transform: rotate(calc(360deg / var(--all) * var(--i)));
  64. transform-origin: 0 160rpx;
  65. animation: loading 2s linear infinite;
  66. animation-delay: calc(var(--i) * 1s);
  67. background-color: green;
  68. }
  69. @keyframes loading {
  70. from {
  71. opacity: 0;
  72. }
  73. to {
  74. opacity: 1;
  75. }
  76. }
  77. .spinner {
  78. margin: 100px auto;
  79. width: 20px;
  80. height: 20px;
  81. position: relative;
  82. }
  83. .container1 > div, .container2 > div, .container3 > div {
  84. width: 6px;
  85. height: 6px;
  86. background-color: #333;
  87. border-radius: 100%;
  88. position: absolute;
  89. -webkit-animation: bouncedelay 1.2s infinite ease-in-out;
  90. animation: bouncedelay 1.2s infinite ease-in-out;
  91. -webkit-animation-fill-mode: both;
  92. animation-fill-mode: both;
  93. }
  94. .spinner .spinner-container {
  95. position: absolute;
  96. width: 100%;
  97. height: 100%;
  98. }
  99. .container2 {
  100. -webkit-transform: rotateZ(45deg);
  101. transform: rotateZ(45deg);
  102. }
  103. .container3 {
  104. -webkit-transform: rotateZ(90deg);
  105. transform: rotateZ(90deg);
  106. }
  107. .circle1 { top: 0; left: 0; }
  108. .circle2 { top: 0; right: 0; }
  109. .circle3 { right: 0; bottom: 0; }
  110. .circle4 { left: 0; bottom: 0; }
  111. .container2 .circle1 {
  112. -webkit-animation-delay: -1.1s;
  113. animation-delay: -1.1s;
  114. }
  115. .container3 .circle1 {
  116. -webkit-animation-delay: -1.0s;
  117. animation-delay: -1.0s;
  118. }
  119. .container1 .circle2 {
  120. -webkit-animation-delay: -0.9s;
  121. animation-delay: -0.9s;
  122. }
  123. .container2 .circle2 {
  124. -webkit-animation-delay: -0.8s;
  125. animation-delay: -0.8s;
  126. }
  127. .container3 .circle2 {
  128. -webkit-animation-delay: -0.7s;
  129. animation-delay: -0.7s;
  130. }
  131. .container1 .circle3 {
  132. -webkit-animation-delay: -0.6s;
  133. animation-delay: -0.6s;
  134. }
  135. .container2 .circle3 {
  136. -webkit-animation-delay: -0.5s;
  137. animation-delay: -0.5s;
  138. }
  139. .container3 .circle3 {
  140. -webkit-animation-delay: -0.4s;
  141. animation-delay: -0.4s;
  142. }
  143. .container1 .circle4 {
  144. -webkit-animation-delay: -0.3s;
  145. animation-delay: -0.3s;
  146. }
  147. .container2 .circle4 {
  148. -webkit-animation-delay: -0.2s;
  149. animation-delay: -0.2s;
  150. }
  151. .container3 .circle4 {
  152. -webkit-animation-delay: -0.1s;
  153. animation-delay: -0.1s;
  154. }
  155. @-webkit-keyframes bouncedelay {
  156. 0%, 80%, 100% { -webkit-transform: scale(0.0) }
  157. 40% { -webkit-transform: scale(1.0) }
  158. }
  159. @keyframes bouncedelay {
  160. 0%, 80%, 100% {
  161. transform: scale(0.0);
  162. -webkit-transform: scale(0.0);
  163. } 40% {
  164. transform: scale(1.0);
  165. -webkit-transform: scale(1.0);
  166. }
  167. }
  168. </style>