fs-divider.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="fs-divider">
  3. <view class="fs-divider-line" :class="['bg-' + (lineColorType || colorType)]" :style="lineStyle"></view>
  4. <view class="fs-divider-content" :class="textColorType || colorType" :style="{ color: textColor || color }">
  5. <slot></slot>
  6. </view>
  7. <view class="fs-divider-line" :class="['bg-' + (lineColorType || colorType)]" :style="lineStyle"></view>
  8. </view>
  9. </template>
  10. <script>
  11. /**
  12. * 分割线组件
  13. * @description 分割线组件
  14. * @property {String} lineWidth 分割线宽度
  15. * @property {String} lineHeight 分割线高度
  16. * @property {String} lineColor 分割线颜色(优先级高于color)
  17. * @property {String} lineColorType = [primary | danger | warning | info | success] 分割线颜色类型(优先级高于colorType)
  18. * @property {String} textColor 文字颜色(优先级高于color)
  19. * @property {String} textColorType = [primary | danger | warning | info | success] 文字颜色类型(优先级高于color)
  20. * @property {String} color 分割线、文字颜色
  21. * @property {String} colorType = [primary | danger | warning | info | success] 分割线、文字颜色类型
  22. */
  23. export default {
  24. name: 'fs-divider'
  25. }
  26. </script>
  27. <script setup>
  28. import { computed } from 'vue'
  29. const props = defineProps({
  30. lineWidth: {
  31. type: String,
  32. default: '150rpx'
  33. },
  34. lineHeight: {
  35. type: String,
  36. default: '2rpx'
  37. },
  38. lineColor: String,
  39. lineColorType: {
  40. type: String,
  41. validator(value) {
  42. return ['primary', 'success', 'info', 'warning', 'danger', 'default'].includes(value)
  43. }
  44. },
  45. textColor: String,
  46. textColorType: {
  47. type: String,
  48. validator(value) {
  49. return ['primary', 'success', 'info', 'warning', 'danger', 'default'].includes(value)
  50. }
  51. },
  52. color: String,
  53. colorType: {
  54. type: String,
  55. default: 'default',
  56. validator(value) {
  57. return ['primary', 'success', 'info', 'warning', 'danger', 'default'].includes(value)
  58. }
  59. }
  60. })
  61. const lineStyle = computed(() => {
  62. return `
  63. width:${props.lineWidth};
  64. height:${props.lineHeight};
  65. backgroundColor:${props.lineColor || props.color};
  66. `
  67. })
  68. </script>
  69. <style lang="scss" scoped>
  70. .fs-divider {
  71. display: flex;
  72. align-items: center;
  73. justify-content: center;
  74. padding: 20rpx;
  75. &-content {
  76. padding: 0 20rpx;
  77. white-space: nowrap;
  78. }
  79. }
  80. </style>