u-divider.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view>
  3. <view class="carNone" v-if="isnone" >
  4. <!-- <img src="@/assets/img/暂无数据-缺省页.png" alt=""> -->
  5. <view style=" margin-top: 40px;">
  6. <u-empty :text="nonetext" mode="search"></u-empty>
  7. </view>
  8. <!-- <p v-text="nonetext" ></p> -->
  9. </view>
  10. <view class="u-divider" v-else :style="{
  11. height: height == 'auto' ? 'auto' : height + 'rpx',
  12. backgroundColor: bgColor,
  13. marginBottom: marginBottom + 'rpx',
  14. marginTop: marginTop + 'rpx'
  15. }" @tap="click">
  16. <view class="u-divider-line" :class="[type ? 'u-divider-line--bordercolor--' + type : '']" :style="[lineStyle]"></view>
  17. <view v-if="useSlot" class="u-divider-text" :style="{
  18. color: color,
  19. fontSize: fontSize + 'rpx'
  20. }"><slot /></view>
  21. <view class="u-divider-line" :class="[type ? 'u-divider-line--bordercolor--' + type : '']" :style="[lineStyle]"></view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. /**
  27. * divider 分割线
  28. * @description 区隔内容的分割线,一般用于页面底部"没有更多"的提示。
  29. * @tutorial https://www.uviewui.com/components/divider.html
  30. * @property {String Number} half-width 文字左或右边线条宽度,数值或百分比,数值时单位为rpx
  31. * @property {String} border-color 线条颜色,优先级高于type(默认#dcdfe6)
  32. * @property {String} color 文字颜色(默认#909399)
  33. * @property {String Number} fontSize 字体大小,单位rpx(默认26)
  34. * @property {String} bg-color 整个divider的背景颜色(默认呢#ffffff)
  35. * @property {String Number} height 整个divider的高度,单位rpx(默认40)
  36. * @property {String} type 将线条设置主题色(默认primary)
  37. * @property {Boolean} useSlot 是否使用slot传入内容,如果不传入,中间不会有空隙(默认true)
  38. * @property {String Number} margin-top 与前一个组件的距离,单位rpx(默认0)
  39. * @property {String Number} margin-bottom 与后一个组件的距离,单位rpx(0)
  40. * @event {Function} click divider组件被点击时触发
  41. * @example <u-divider color="#fa3534">长河落日圆</u-divider>
  42. */
  43. export default {
  44. name: 'u-divider',
  45. props: {
  46. isnone:{
  47. //是否列表显示为空
  48. type: Boolean,
  49. default:false,
  50. },
  51. nonetext: {
  52. //列表显示为空显示文字
  53. type: String,
  54. default: '没有找到相关内容'
  55. },
  56. // 单一边divider横线的宽度(数值),单位rpx。或者百分比
  57. halfWidth: {
  58. type: [Number, String],
  59. default: 150
  60. },
  61. // divider横线的颜色,如设置,
  62. borderColor: {
  63. type: String,
  64. default: '#dcdfe6'
  65. },
  66. // 主题色,可以是primary|info|success|warning|error之一值
  67. type: {
  68. type: String,
  69. default: 'primary'
  70. },
  71. // 文字颜色
  72. color: {
  73. type: String,
  74. default: '#909399'
  75. },
  76. // 文字大小,单位rpx
  77. fontSize: {
  78. type: [Number, String],
  79. default: 26
  80. },
  81. // 整个divider的背景颜色
  82. bgColor: {
  83. type: String,
  84. default: '#f4f4f4'
  85. },
  86. // 整个divider的高度单位rpx
  87. height: {
  88. type: [Number, String],
  89. default: 'auto'
  90. },
  91. // 上边距
  92. marginTop: {
  93. type: [String, Number],
  94. default: 0
  95. },
  96. // 下边距
  97. marginBottom: {
  98. type: [String, Number],
  99. default: 0
  100. },
  101. // 是否使用slot传入内容,如果不用slot传入内容,先的中间就不会有空隙
  102. useSlot: {
  103. type: Boolean,
  104. default: true
  105. }
  106. },
  107. computed: {
  108. lineStyle() {
  109. let style = {};
  110. if(String(this.halfWidth).indexOf('%') != -1) style.width = this.halfWidth;
  111. else style.width = this.halfWidth + 'rpx';
  112. // borderColor优先级高于type值
  113. if(this.borderColor) style.borderColor = this.borderColor;
  114. return style;
  115. }
  116. },
  117. methods: {
  118. click() {
  119. this.$emit('click');
  120. }
  121. }
  122. };
  123. </script>
  124. <style lang="scss" scoped>
  125. @import "../../libs/css/style.components.scss";
  126. .u-divider {
  127. width: 100%;
  128. position: relative;
  129. text-align: center;
  130. @include vue-flex;
  131. justify-content: center;
  132. align-items: center;
  133. overflow: hidden;
  134. flex-direction: row;
  135. }
  136. .u-divider-line {
  137. border-bottom: 1px solid $u-border-color;
  138. transform: scale(1, 0.5);
  139. transform-origin: center;
  140. &--bordercolor--primary {
  141. border-color: $u-type-primary;
  142. }
  143. &--bordercolor--success {
  144. border-color: $u-type-success;
  145. }
  146. &--bordercolor--error {
  147. border-color: $u-type-primary;
  148. }
  149. &--bordercolor--info {
  150. border-color: $u-type-info;
  151. }
  152. &--bordercolor--warning {
  153. border-color: $u-type-warning;
  154. }
  155. }
  156. .u-divider-text {
  157. white-space: nowrap;
  158. padding: 0 16rpx;
  159. /* #ifndef APP-NVUE */
  160. display: inline-flex;
  161. /* #endif */
  162. }
  163. .carNone{
  164. display: flex;
  165. flex-direction: column;
  166. justify-content: center;
  167. align-items: center;
  168. img{
  169. width: 100%;
  170. height: 100%;
  171. }
  172. p{
  173. margin-top: -60px;
  174. }
  175. }
  176. </style>