di-descriptions.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <u-cell-group class="di-descriptions" :border="border">
  3. <u-cell-item :arrow="false" :use-label-slot='true' :border-bottom='borderBottom' :border-top="false">
  4. <template #title>
  5. <view class="di-descriptions__title" :class="{'u-border-bottom': titleBottom}">
  6. <view class="di-descriptions__title-left">
  7. <slot name="title">
  8. <text v-if="title">{{title}}</text>
  9. </slot>
  10. </view>
  11. <view class="di-descriptions__title-right">
  12. <slot name="right"></slot>
  13. </view>
  14. </view>
  15. </template>
  16. <template slot="label">
  17. <view class="di-descriptions__body">
  18. <slot></slot>
  19. </view>
  20. </template>
  21. </u-cell-item>
  22. </u-cell-group>
  23. </template>
  24. <script>
  25. /**
  26. * di-descriptions 描述列表
  27. * @description 描述列表,用于展示label value的值,常见于详情页的信息展示。 搭配 di-descriptions-item
  28. * @property {String slot} title 头部信息,也可以使用插槽
  29. * @property {String slot} right 插槽
  30. * @property {Boolean} border 是否显示边框(默认false)
  31. * @property {Boolean} border-bottom 是否显示底部边框,与border分开使用,单位rpx(默认false)
  32. * @property {Boolean} title-bottom 是否显示title底部边框,单位rpx(默认false)
  33. * @property {Number String} label-col label宽度,等分12份,设置后子元素di-descriptions-item可以继承
  34. * @property {Number String} value-col value宽度,等分12份,设置后子元素di-descriptions-item可以继承
  35. */
  36. export default {
  37. // #ifdef MP-WEIXIN
  38. // 解决小程序样式无法使用
  39. options: { styleIsolation: 'shared' },
  40. // #endif
  41. name: 'DiDescriptions',
  42. props: {
  43. title: {
  44. type: String | Number
  45. },
  46. border: {
  47. type: Boolean,
  48. default: false
  49. },
  50. borderBottom: {
  51. type: Boolean,
  52. default: false
  53. },
  54. titleBottom: {
  55. type: Boolean,
  56. default: false
  57. },
  58. labelCol: {
  59. type: String | Number,
  60. default: 3
  61. },
  62. valueCol: {
  63. type: String | Number,
  64. default: 9
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss">
  70. .di-descriptions {
  71. // width: 100%;
  72. /deep/.u-cell_title {
  73. width: 100% !important;
  74. }
  75. &__title {
  76. font-weight: bold;
  77. display: flex;
  78. justify-content: space-between;
  79. padding-bottom: 5px;
  80. &-right{
  81. min-width: 60px;
  82. text-align: right;
  83. }
  84. }
  85. }
  86. </style>