u-gap.vue 1.4 KB

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