van_field.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <div class="van_field_bg">
  3. <van-field
  4. :required="isRequired"
  5. :label="label"
  6. :placeholder="placeholder"
  7. readonly
  8. >
  9. <template v-if="item.child_list && item.child_list.length" #input>
  10. <template v-for="(v, i) in item.child_list" :key="i">
  11. <h5-van-radio-group
  12. :item="v"
  13. v-if="v.type === 'van-radio-group'"
  14. ></h5-van-radio-group>
  15. <h5-van-uploader
  16. :item="v"
  17. v-if="v.type === 'van-uploader'"
  18. ></h5-van-uploader>
  19. </template>
  20. </template>
  21. </van-field>
  22. <div class="van_field_item"></div>
  23. </div>
  24. </template>
  25. <script setup>
  26. import H5VanRadioGroup from './van_radio_group.vue';
  27. import H5VanUploader from './van_uploader.vue';
  28. import { ref, defineProps } from 'vue';
  29. const label = ref('');
  30. const placeholder = ref('');
  31. const isRequired = ref(false);
  32. const props = defineProps({
  33. item: Object,
  34. });
  35. const item = JSON.parse(JSON.stringify(props.item || '{}'));
  36. label.value = item.attr.label || item.attr.name;
  37. placeholder.value = item.attr.placeholder;
  38. </script>
  39. <style scoped>
  40. .van_field_bg {
  41. position: relative;
  42. }
  43. .van_field_item {
  44. position: absolute;
  45. top: 0;
  46. left: 0;
  47. right: 0;
  48. bottom: 0;
  49. z-index: 1;
  50. }
  51. .van_field_item:hover{
  52. background-color: #00000080;
  53. }
  54. </style>