uni-group.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="uni-group" :class="['uni-group--'+mode]" :style="{marginTop: `${top}px` }">
  3. <slot name="title">
  4. <view v-if="title" class="uni-group__title">
  5. <text class="uni-group__title-text">{{ title }}</text>
  6. </view>
  7. </slot>
  8. <view class="uni-group__content">
  9. <slot />
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. /**
  15. * Group 分组
  16. * @description 表单字段分组
  17. * @tutorial https://ext.dcloud.net.cn/plugin?id=21002
  18. * @property {String} title 主标题
  19. * @property {Number} top 分组间隔
  20. */
  21. export default {
  22. name: 'UniFormGroup',
  23. props: {
  24. title: {
  25. type: String,
  26. default: ''
  27. },
  28. top: {
  29. type: [Number, String],
  30. default: 10
  31. },
  32. mode:{
  33. type:String,
  34. default:'default'
  35. }
  36. },
  37. data() {
  38. return {}
  39. },
  40. watch: {
  41. title(newVal) {
  42. if (uni.report && newVal !== '') {
  43. uni.report('title', newVal)
  44. }
  45. }
  46. },
  47. methods: {
  48. onClick() {
  49. this.$emit('click')
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .uni-group {
  56. background: #fff;
  57. margin-top: 10px;
  58. // border: 1px red solid;
  59. }
  60. .uni-group__title {
  61. /* #ifndef APP-NVUE */
  62. display: flex;
  63. /* #endif */
  64. align-items: center;
  65. padding-left: 15px;
  66. height: 40px;
  67. background-color: $uni-bg-color-grey;
  68. font-weight: normal;
  69. color: $uni-text-color;
  70. }
  71. .uni-group__content {
  72. padding: 15px;
  73. padding-bottom: 5px;
  74. background-color: #FFF;
  75. }
  76. .uni-group__title-text {
  77. font-size: $uni-font-size-base;
  78. color: $uni-text-color;
  79. }
  80. .distraction {
  81. flex-direction: row;
  82. align-items: center;
  83. }
  84. .uni-group--card {
  85. margin: 10px;
  86. border-radius: 5px;
  87. overflow: hidden;
  88. box-shadow: 0 0 5px 1px rgba($color: #000000, $alpha: 0.08);
  89. }
  90. </style>