u-gap.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <template>
  2. <view class="u-gap" :style="[gapStyle]"></view>
  3. </template>
  4. <script>
  5. import props from './props.js';
  6. /**
  7. * gap 间隔槽
  8. * @description 该组件一般用于内容块之间的用一个灰色块隔开的场景,方便用户风格统一,减少工作量
  9. * @tutorial https://www.uviewui.com/components/gap.html
  10. * @property {String} bgColor 背景颜色 (默认 'transparent' )
  11. * @property {String | Number} height 分割槽高度,单位px (默认 20 )
  12. * @property {String | Number} marginTop 与前一个组件的距离,单位px( 默认 0 )
  13. * @property {String | Number} marginBottom 与后一个组件的距离,单位px (默认 0 )
  14. * @property {Object} customStyle 定义需要用到的外部样式
  15. *
  16. * @example <u-gap height="80" bg-color="#bbb"></u-gap>
  17. */
  18. export default {
  19. name: "u-gap",
  20. mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
  21. computed: {
  22. gapStyle() {
  23. const style = {
  24. backgroundColor: this.bgColor,
  25. height: uni.$u.addUnit(this.height),
  26. marginTop: uni.$u.addUnit(this.marginTop),
  27. marginBottom: uni.$u.addUnit(this.marginBottom),
  28. }
  29. return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
  30. }
  31. }
  32. };
  33. </script>
  34. <style lang="scss" scoped>
  35. @import "../../libs/css/components.scss";
  36. </style>