综合办公系统
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.

uv-divider.vue 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view
  3. class="uv-divider"
  4. :style="[$uv.addStyle(customStyle)]"
  5. @tap="click"
  6. >
  7. <uv-line
  8. :color="lineColor"
  9. :customStyle="leftLineStyle"
  10. :hairline="hairline"
  11. :dashed="dashed"></uv-line>
  12. <text
  13. v-if="dot"
  14. class="uv-divider__dot"
  15. >●</text>
  16. <text
  17. v-else-if="text"
  18. class="uv-divider__text"
  19. :style="[textStyle]"
  20. >{{text}}</text>
  21. <uv-line
  22. :color="lineColor"
  23. :customStyle="rightLineStyle"
  24. :hairline="hairline"
  25. :dashed="dashed"
  26. ></uv-line>
  27. </view>
  28. </template>
  29. <script>
  30. import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
  31. import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
  32. import props from './props.js';
  33. /**
  34. * divider 分割线
  35. * @description 区隔内容的分割线,一般用于页面底部"没有更多"的提示。
  36. * @tutorial https://www.uvui.cn/components/divider.html
  37. * @property {Boolean} dashed 是否虚线 (默认 false )
  38. * @property {Boolean} hairline 是否细线 (默认 true )
  39. * @property {Boolean} dot 是否以点替代文字,优先于text字段起作用 (默认 false )
  40. * @property {String} textPosition 内容文本的位置,left-左边,center-中间,right-右边 (默认 'center' )
  41. * @property {String | Number} text 文本内容
  42. * @property {String | Number} textSize 文本大小 (默认 14)
  43. * @property {String} textColor 文本颜色 (默认 '#909399' )
  44. * @property {String} lineColor 线条颜色 (默认 '#dcdfe6' )
  45. * @property {Object} customStyle 定义需要用到的外部样式
  46. *
  47. * @event {Function} click divider组件被点击时触发
  48. * @example <uv-divider :color="color">锦瑟无端五十弦</uv-divider>
  49. */
  50. export default {
  51. name: 'uv-divider',
  52. mixins: [mpMixin, mixin, props],
  53. emits: ['click'],
  54. computed: {
  55. textStyle() {
  56. const style = {}
  57. style.fontSize = this.$uv.addUnit(this.textSize)
  58. style.color = this.textColor
  59. return style
  60. },
  61. // 左边线条的的样式
  62. leftLineStyle() {
  63. const style = {}
  64. // 如果是在左边,设置左边的宽度为固定值
  65. if (this.textPosition === 'left') {
  66. style.width = '80rpx'
  67. } else {
  68. style.flex = 1
  69. }
  70. return style
  71. },
  72. // 右边线条的的样式
  73. rightLineStyle() {
  74. const style = {}
  75. // 如果是在右边,设置右边的宽度为固定值
  76. if (this.textPosition === 'right') {
  77. style.width = '80rpx'
  78. } else {
  79. style.flex = 1
  80. }
  81. return style
  82. }
  83. },
  84. methods: {
  85. // divider组件被点击时触发
  86. click() {
  87. this.$emit('click');
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. @import '@/uni_modules/uv-ui-tools/libs/css/components.scss';
  94. $uv-divider-margin: 15px 0 !default;
  95. $uv-divider-text-margin: 0 15px !default;
  96. $uv-divider-dot-font-size: 12px !default;
  97. $uv-divider-dot-margin: 0 12px !default;
  98. $uv-divider-dot-color: #c0c4cc !default;
  99. .uv-divider {
  100. @include flex;
  101. flex-direction: row;
  102. align-items: center;
  103. margin: $uv-divider-margin;
  104. &__text {
  105. margin: $uv-divider-text-margin;
  106. }
  107. &__dot {
  108. font-size: $uv-divider-dot-font-size;
  109. margin: $uv-divider-dot-margin;
  110. color: $uv-divider-dot-color;
  111. }
  112. }
  113. </style>