You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.4 KiB

2 months ago
  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://ijry.github.io/uview-plus/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 style = {
  27. backgroundColor: this.bgColor,
  28. height: addUnit(this.height),
  29. marginTop: addUnit(this.marginTop),
  30. marginBottom: addUnit(this.marginBottom),
  31. }
  32. return deepMerge(style, addStyle(this.customStyle))
  33. }
  34. }
  35. };
  36. </script>
  37. <style lang="scss" scoped>
  38. @import "../../libs/css/components.scss";
  39. </style>