uni-group.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <view class="uni-group" :style="{marginTop: `${top}px` }">
  3. <view v-if="title" class="uni-group__content">
  4. <text class="uni-group__content-title">{{ title }}</text>
  5. </view>
  6. <slot />
  7. </view>
  8. </template>
  9. <script>
  10. /**
  11. * Group 分组
  12. * @description 表单字段分组
  13. * @tutorial https://ext.dcloud.net.cn/plugin?id=21002
  14. * @property {String} title 主标题
  15. * @property {Number} top 分组间隔
  16. */
  17. export default {
  18. name: 'UniFormGroup',
  19. props: {
  20. title: {
  21. type: String,
  22. default: ''
  23. },
  24. top: {
  25. type: [Number, String],
  26. default: 10
  27. }
  28. },
  29. data() {
  30. return {}
  31. },
  32. watch: {
  33. title(newVal) {
  34. if (uni.report && newVal !== '') {
  35. uni.report('title', newVal)
  36. }
  37. }
  38. },
  39. methods: {
  40. onClick() {
  41. this.$emit('click')
  42. }
  43. }
  44. }
  45. </script>
  46. <style scoped>
  47. .uni-group {
  48. background: #fff;
  49. margin-top: 10px;
  50. }
  51. .uni-group__content {
  52. /* #ifndef APP-NVUE */
  53. display: flex;
  54. /* #endif */
  55. align-items: center;
  56. padding-left: 15px;
  57. height: 40px;
  58. background-color: #f8f8f8;
  59. font-weight: normal;
  60. color: #333;
  61. }
  62. .uni-group__content-title {
  63. font-size: 14px;
  64. color: #333;
  65. }
  66. .distraction {
  67. flex-direction: row;
  68. align-items: center;
  69. }
  70. </style>