u-divider.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view>
  3. <view class="carNone" v-if="isnone" >
  4. <!-- <img src="@/assets/img/暂无数据-缺省页.png" alt=""> -->
  5. <view :style=" 'margin-top: '+nonetop+'px;'">
  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. nonetop: {
  57. //列表显示为空显示文字
  58. type: Number,
  59. default: 80
  60. },
  61. // 单一边divider横线的宽度(数值),单位rpx。或者百分比
  62. halfWidth: {
  63. type: [Number, String],
  64. default: 150
  65. },
  66. // divider横线的颜色,如设置,
  67. borderColor: {
  68. type: String,
  69. default: '#dcdfe6'
  70. },
  71. // 主题色,可以是primary|info|success|warning|error之一值
  72. type: {
  73. type: String,
  74. default: 'primary'
  75. },
  76. // 文字颜色
  77. color: {
  78. type: String,
  79. default: '#909399'
  80. },
  81. // 文字大小,单位rpx
  82. fontSize: {
  83. type: [Number, String],
  84. default: 26
  85. },
  86. // 整个divider的背景颜色
  87. bgColor: {
  88. type: String,
  89. default: '#f4f4f4'
  90. },
  91. // 整个divider的高度单位rpx
  92. height: {
  93. type: [Number, String],
  94. default: 'auto'
  95. },
  96. // 上边距
  97. marginTop: {
  98. type: [String, Number],
  99. default: 0
  100. },
  101. // 下边距
  102. marginBottom: {
  103. type: [String, Number],
  104. default: 0
  105. },
  106. // 是否使用slot传入内容,如果不用slot传入内容,先的中间就不会有空隙
  107. useSlot: {
  108. type: Boolean,
  109. default: true
  110. }
  111. },
  112. computed: {
  113. lineStyle() {
  114. let style = {};
  115. if(String(this.halfWidth).indexOf('%') != -1) style.width = this.halfWidth;
  116. else style.width = this.halfWidth + 'rpx';
  117. // borderColor优先级高于type值
  118. if(this.borderColor) style.borderColor = this.borderColor;
  119. return style;
  120. }
  121. },
  122. methods: {
  123. click() {
  124. this.$emit('click');
  125. }
  126. }
  127. };
  128. </script>
  129. <style lang="scss" scoped>
  130. @import "../../libs/css/style.components.scss";
  131. .u-divider {
  132. width: 100%;
  133. position: relative;
  134. text-align: center;
  135. @include vue-flex;
  136. justify-content: center;
  137. align-items: center;
  138. overflow: hidden;
  139. flex-direction: row;
  140. }
  141. .u-divider-line {
  142. border-bottom: 1px solid $u-border-color;
  143. transform: scale(1, 0.5);
  144. transform-origin: center;
  145. &--bordercolor--primary {
  146. border-color: $u-type-primary;
  147. }
  148. &--bordercolor--success {
  149. border-color: $u-type-success;
  150. }
  151. &--bordercolor--error {
  152. border-color: $u-type-primary;
  153. }
  154. &--bordercolor--info {
  155. border-color: $u-type-info;
  156. }
  157. &--bordercolor--warning {
  158. border-color: $u-type-warning;
  159. }
  160. }
  161. .u-divider-text {
  162. white-space: nowrap;
  163. padding: 0 16rpx;
  164. /* #ifndef APP-NVUE */
  165. display: inline-flex;
  166. /* #endif */
  167. }
  168. .carNone{
  169. display: flex;
  170. flex-direction: column;
  171. justify-content: center;
  172. align-items: center;
  173. img{
  174. width: 100%;
  175. height: 100%;
  176. }
  177. p{
  178. margin-top: -60px;
  179. }
  180. }
  181. </style>