Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

45 linhas
1.6 KiB

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