RadioValue.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <FlexView :direction="vertical ? 'column' : 'row'" align="center" :gap="10" wrap>
  3. <RadioGroup
  4. :modelValue="modelValue"
  5. @update:modelValue="emits('update:modelValue', $event)"
  6. :disabled="disabled"
  7. v-bind="$attrs"
  8. >
  9. <Radio
  10. v-for="it in options"
  11. :key="(it.value as string)"
  12. :name="(it.value as string)"
  13. :text="it.text"
  14. />
  15. </RadioGroup>
  16. </FlexView>
  17. </template>
  18. <script lang="ts" setup>
  19. import { type PropType, ref, watch, onMounted } from 'vue';
  20. import RadioGroup from '@/components/form/RadioGroup.vue';
  21. import Radio from '@/components/form/Radio.vue';
  22. import type { RadioValueOption } from './RadioValue';
  23. import FlexView from '@/components/layout/FlexView.vue';
  24. const props = defineProps({
  25. /**
  26. * 是否禁用
  27. */
  28. disabled: {
  29. type: Boolean,
  30. default: false
  31. },
  32. /**
  33. * 是否垂直方向
  34. */
  35. vertical: {
  36. type: Boolean,
  37. default: false
  38. },
  39. /**
  40. * 选项数据
  41. */
  42. options: {
  43. type: Object as PropType<RadioValueOption[]>,
  44. default: null,
  45. },
  46. modelValue: {
  47. type: [String, Number],
  48. default: null,
  49. },
  50. });
  51. const emits = defineEmits([
  52. 'update:modelValue',
  53. ]);
  54. </script>