index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="skeleton-box">
  3. <view v-if="loading" class="skeleton">
  4. <!-- <text>数据加载中...</text> -->
  5. <div class="spinner">
  6. <div></div>
  7. <div></div>
  8. <div></div>
  9. <div></div>
  10. <div></div>
  11. </div>
  12. <!-- <view class="led" :style="{'--i':index,'--all':25}" v-for="(item,index) in 25" :key='index' /> -->
  13. </view>
  14. <van-transition v-else-if="list.length==0" name="fade-up">
  15. <view class="skeleton">
  16. 暂时没有数据
  17. </view>
  18. </van-transition>
  19. <van-transition v-else name="fade-up">
  20. <slot></slot>
  21. </van-transition>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. props: {
  27. loading: {
  28. type: Boolean,
  29. default: true
  30. },
  31. list: {
  32. type: Array,
  33. default: [1]
  34. }
  35. }
  36. }
  37. </script>
  38. <style lang="scss" scoped>
  39. .skeleton {
  40. display: flex;
  41. justify-content: center;
  42. align-items: center;
  43. padding: 50rpx;
  44. height: 320rpx;
  45. }
  46. .led {
  47. width: 10rpx;
  48. height: 30rpx;
  49. border-radius: 10rpx;
  50. top: 50rpx;
  51. position: absolute;
  52. transform: rotate(calc(360deg / var(--all) * var(--i)));
  53. transform-origin: 0 160rpx;
  54. animation: loading 2s linear infinite;
  55. animation-delay: calc(var(--i) * 1s);
  56. background-color: green;
  57. }
  58. @keyframes loading {
  59. from {
  60. opacity: 0;
  61. }
  62. to {
  63. opacity: 1;
  64. }
  65. }
  66. .spinner {
  67. margin: 100px auto;
  68. width: 50px;
  69. height: 50px;
  70. text-align: center;
  71. font-size: 10px;
  72. }
  73. .spinner>div {
  74. display: inline-block;
  75. background-color: rgb(55, 226, 83);
  76. height: 100%;
  77. width: 5px;
  78. margin-right: 1px;
  79. animation: bytedance 1s infinite;
  80. }
  81. .spinner>div:nth-of-type(2) {
  82. background-color: rgb(41, 124, 54);
  83. animation-delay: -0.9s;
  84. }
  85. .spinner>div:nth-child(3) {
  86. background-color: rgb(45, 173, 22);
  87. animation-delay: -0.8s;
  88. }
  89. .spinner>div:nth-child(4) {
  90. background-color: rgb(154, 173, 153);
  91. animation-delay: -0.7s;
  92. }
  93. .spinner>div:nth-child(5) {
  94. background-color: rgb(22, 240, 77);
  95. animation-delay: -0.6s;
  96. }
  97. @keyframes bytedance {
  98. 0%,
  99. 40%,
  100. 100% {
  101. transform: scaleY(0.4);
  102. }
  103. 20% {
  104. transform: scaleY(1);
  105. }
  106. }
  107. </style>