fs-divider.vue 1.5 KB

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