index.vue 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <uni-shadow-root class="vant-skeleton-index"><view v-if="loading" :class="'custom-class '+(utils.bem('skeleton', [{animate}]))">
  3. <view v-if="avatar" :class="utils.bem('skeleton__avatar', [avatarShape])" :style="'width:' + avatarSize + ';height:' + avatarSize"></view>
  4. <view :class="utils.bem('skeleton__content')">
  5. <view v-if="title" :class="utils.bem('skeleton__title')" :style="'width:' + titleWidth"></view>
  6. <view v-for="(item,index) in (row)" :key="item.index" :class="utils.bem('skeleton__row')" :style="'width:' + (isArray ? rowWidth[index] : rowWidth)"></view>
  7. </view>
  8. </view>
  9. <view v-else :class="utils.bem('skeleton__content')">
  10. <slot></slot>
  11. </view></uni-shadow-root>
  12. </template>
  13. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  14. <script>
  15. global['__wxVueOptions'] = {components:{}}
  16. global['__wxRoute'] = 'vant/skeleton/index'
  17. import { VantComponent } from '../common/component';
  18. VantComponent({
  19. props: {
  20. row: {
  21. type: Number,
  22. value: 0
  23. },
  24. title: Boolean,
  25. avatar: Boolean,
  26. loading: {
  27. type: Boolean,
  28. value: true
  29. },
  30. animate: {
  31. type: Boolean,
  32. value: true
  33. },
  34. avatarSize: {
  35. type: String,
  36. value: '32px'
  37. },
  38. avatarShape: {
  39. type: String,
  40. value: 'round'
  41. },
  42. titleWidth: {
  43. type: String,
  44. value: '40%'
  45. },
  46. rowWidth: {
  47. type: null,
  48. value: '100%',
  49. observer(val) {
  50. this.setData({ isArray: val instanceof Array });
  51. }
  52. }
  53. },
  54. data: {
  55. isArray: false
  56. }
  57. });
  58. export default global['__wxComponents']['vant/skeleton/index']
  59. </script>
  60. <style platform="mp-weixin">
  61. @import '../common/index.css';.van-skeleton{display:-webkit-flex;display:flex;box-sizing:border-box;width:100%;padding:0 16px;padding:var(--skeleton-padding,0 16px)}.van-skeleton__avatar{-webkit-flex-shrink:0;flex-shrink:0;margin-right:16px;margin-right:var(--padding-md,16px);background-color:#f2f3f5;background-color:var(--skeleton-avatar-background-color,#f2f3f5)}.van-skeleton__avatar--round{border-radius:100%}.van-skeleton__content{-webkit-flex:1;flex:1}.van-skeleton__avatar+.van-skeleton__content{padding-top:8px;padding-top:var(--padding-xs,8px)}.van-skeleton__row,.van-skeleton__title{height:16px;height:var(--skeleton-row-height,16px);background-color:#f2f3f5;background-color:var(--skeleton-row-background-color,#f2f3f5)}.van-skeleton__title{margin:0}.van-skeleton__row:not(:first-child){margin-top:12px;margin-top:var(--skeleton-row-margin-top,12px)}.van-skeleton__title+.van-skeleton__row{margin-top:20px}.van-skeleton--animate{-webkit-animation:van-skeleton-blink 1.2s ease-in-out infinite;animation:van-skeleton-blink 1.2s ease-in-out infinite}@-webkit-keyframes van-skeleton-blink{50%{opacity:.6}}@keyframes van-skeleton-blink{50%{opacity:.6}}
  62. </style>