wike-skeleton.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view>
  3. <view class="placeholder question" v-for="(item,index) in size" :key="index">
  4. <block v-if="type==='question'">
  5. <view class="ph-title"></view>
  6. <view class="ph-name"></view>
  7. <view class="ph-text"></view>
  8. <view class="ph-text"></view>
  9. </block>
  10. <block v-if="type==='user'">
  11. <view class="ph-avatar"></view>
  12. <view class="user-info">
  13. <view class="ph-name"></view>
  14. <view class="ph-text"></view>
  15. <view class="ph-text"></view>
  16. </view>
  17. </block>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. props: {
  24. count: {
  25. type: Number,
  26. default: 1
  27. },
  28. type: {
  29. type: String,
  30. default: "question"
  31. }
  32. },
  33. data() {
  34. return {
  35. size: this.myReduce(this.count)
  36. }
  37. },
  38. methods: {
  39. // reduce 斐波那契数列
  40. myReduce(n) {
  41. return [...new Array(n).keys()].reduce((t, v) => {
  42. v > 1 && t.push(t[v - 1] + t[v - 2])
  43. return t
  44. }, [1, 1])
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss" scoped>
  50. .placeholder {
  51. background: var(--empty-bg--);
  52. border-radius: 24rpx;
  53. display: flex;
  54. flex-direction: column;
  55. margin: 0 24rpx 20rpx;
  56. padding: 40rpx 32rpx;
  57. }
  58. .placeholder:nth-of-type(1) {
  59. margin-top: 0;
  60. }
  61. .placeholder [class*="ph-"] {
  62. background-color: #fafbfc;
  63. margin-bottom: 24rpx;
  64. overflow: hidden;
  65. position: relative;
  66. width: 100%;
  67. }
  68. .placeholder [class*="ph-"]::before {
  69. animation-duration: 1.5s;
  70. animation-fill-mode: forwards;
  71. animation-iteration-count: infinite;
  72. animation-name: PlaceholdersAnimation;
  73. animation-timing-function: linear;
  74. background: linear-gradient(90deg, transparent 0, rgba(0, 0, 0, .02) 20%, transparent 40%);
  75. content: "";
  76. height: 100%;
  77. left: 0;
  78. max-width: 1000px;
  79. position: absolute;
  80. top: 0;
  81. width: 100vw;
  82. }
  83. .placeholder [class*="ph-"]:last-child {
  84. margin-bottom: 0;
  85. }
  86. .placeholder.user {
  87. flex-direction: row;
  88. }
  89. .placeholder.user .user-info {
  90. flex: 1;
  91. }
  92. .placeholder .ph-title {
  93. height: 54rpx;
  94. }
  95. .placeholder .ph-name {
  96. height: 48rpx;
  97. width: 240rpx;
  98. }
  99. .placeholder .ph-text {
  100. height: 32rpx;
  101. margin-bottom: 16rpx;
  102. }
  103. .placeholder .ph-avatar {
  104. border-radius: 50%;
  105. flex-shrink: 0;
  106. height: 88rpx;
  107. margin-right: 24rpx;
  108. width: 88rpx;
  109. }
  110. @-webkit-keyframes PlaceholdersAnimation {
  111. 0% {
  112. transform: translate3d(-30%, 0, 0);
  113. }
  114. 100% {
  115. transform: translate3d(100%, 0, 0);
  116. }
  117. }
  118. @keyframes PlaceholdersAnimation {
  119. 0% {
  120. transform: translate3d(-30%, 0, 0);
  121. }
  122. 100% {
  123. transform: translate3d(100%, 0, 0);
  124. }
  125. }
  126. </style>