tm-skeleton.vue 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="tm-skeleton fulled">
  3. <view v-if="model=='card'">
  4. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class=" tm-skeleton-card"></view>
  5. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24"></view>
  6. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" style="width: 60%;"></view>
  7. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" style="width: 30%;"></view>
  8. </view>
  9. <view v-if="model=='cardActions'">
  10. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class=" tm-skeleton-card"></view>
  11. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24"></view>
  12. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item " ></view>
  13. <view class="flex-between">
  14. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" style="width: 40%;"></view>
  15. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" style="width: 15%;"></view>
  16. </view>
  17. </view>
  18. <view v-if="model=='list'">
  19. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" style="width: 60%;"></view>
  20. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" ></view>
  21. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" ></view>
  22. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" style="width: 30%;"></view>
  23. </view>
  24. <view v-if="model=='listAvatr'" class="flex-top-start">
  25. <view style="width: 100rpx;height: 100rpx;" :class="[$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="rounded flex-shrink mr-32"></view>
  26. <view class="fulled">
  27. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item mb-24" style="width: 60%;"></view>
  28. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" ></view>
  29. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" ></view>
  30. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item my-24" style="width: 30%;"></view>
  31. </view>
  32. </view>
  33. <view v-if="model=='grid'" class="flex-top-start flex-wrap">
  34. <view v-for="(item,index) in 16" :key="index" style="width: 25%;">
  35. <view :class="[`round-${round}`,$tm.vx.state().tmVuetify.black ? 'black bk' : '',color]" class="tm-skeleton-item ma-12" style="height: 80rpx;"></view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. /**
  42. * 骨架加载器
  43. * @property {String} model = [card|cardActions|list|listAvatr|grid] 默认card类型
  44. * @property {Number} round = [] 默认6,圆角
  45. * @property {String} color = [] 默认grey-lighten-3,背景色
  46. */
  47. export default {
  48. name:"tm-skeleton",
  49. props:{
  50. model:{
  51. type:String,
  52. default:'card',//card,cardActions,list,listAvatr,listAvatr,grid
  53. },
  54. round:{
  55. type:Number|String,
  56. default:6
  57. },
  58. color:{
  59. type:String,
  60. default:'grey-lighten-3'
  61. }
  62. },
  63. data() {
  64. return {
  65. };
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .tm-skeleton{
  71. animation: ssy 1s ease infinite;
  72. .tm-skeleton-card{
  73. height: 300rpx;
  74. }
  75. .tm-skeleton-item{
  76. height: 40rpx;
  77. }
  78. }
  79. @keyframes ssy{
  80. 0%{
  81. opacity: 0.4;
  82. }
  83. 50%{
  84. opacity: 1;
  85. }
  86. 100%{
  87. opacity: 0.4;
  88. }
  89. }
  90. </style>