u-divider.vue 4.6 KB

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