index.vue 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <uni-shadow-root class="weapp-lib-skeleton-index"><view v-if="loading" :class="'custom-class '+(utils.bem('skeleton', [{animate}]))">
  3. <view v-if="avatar" :class="'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="'title-class '+(utils.bem('skeleton__title'))" :style="'width:' + titleWidth"></view>
  6. <view v-for="(item,index) in (rowArray)" :key="item.index" :class="'row-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'] = 'weapp/lib/skeleton/index'
  17. "use strict";
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. var component_1 = require("../common/component");
  20. (0, component_1.VantComponent)({
  21. classes: ['avatar-class', 'title-class', 'row-class'],
  22. props: {
  23. row: {
  24. type: Number,
  25. value: 0,
  26. observer: function (value) {
  27. this.setData({ rowArray: Array.from({ length: value }) });
  28. },
  29. },
  30. title: Boolean,
  31. avatar: Boolean,
  32. loading: {
  33. type: Boolean,
  34. value: true,
  35. },
  36. animate: {
  37. type: Boolean,
  38. value: true,
  39. },
  40. avatarSize: {
  41. type: String,
  42. value: '32px',
  43. },
  44. avatarShape: {
  45. type: String,
  46. value: 'round',
  47. },
  48. titleWidth: {
  49. type: String,
  50. value: '40%',
  51. },
  52. rowWidth: {
  53. type: null,
  54. value: '100%',
  55. observer: function (val) {
  56. this.setData({ isArray: val instanceof Array });
  57. },
  58. },
  59. },
  60. data: {
  61. isArray: false,
  62. rowArray: [],
  63. },
  64. });
  65. export default global['__wxComponents']['weapp/lib/skeleton/index']
  66. </script>
  67. <style platform="mp-weixin">
  68. @import '../common/index.css';.van-skeleton{box-sizing:border-box;display:flex;padding:var(--skeleton-padding,0 16px);width:100%}.van-skeleton__avatar{background-color:var(--skeleton-avatar-background-color,#f2f3f5);flex-shrink:0;margin-right:var(--padding-md,16px)}.van-skeleton__avatar--round{border-radius:100%}.van-skeleton__content{flex:1}.van-skeleton__avatar+.van-skeleton__content{padding-top:var(--padding-xs,8px)}.van-skeleton__row,.van-skeleton__title{background-color:var(--skeleton-row-background-color,#f2f3f5);height:var(--skeleton-row-height,16px)}.van-skeleton__title{margin:0}.van-skeleton__row:not(:first-child){margin-top:var(--skeleton-row-margin-top,12px)}.van-skeleton__title+.van-skeleton__row{margin-top:20px}.van-skeleton--animate{animation:van-skeleton-blink 1.2s ease-in-out infinite}@keyframes van-skeleton-blink{50%{opacity:.6}}
  69. </style>