Select.vue 873 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <script lang="ts" setup>
  2. import { defineAsyncComponent } from "vue";
  3. const Input = defineAsyncComponent(
  4. () => import("@/pages/NewStation/Components/Input.vue")
  5. );
  6. withDefaults(
  7. defineProps<{
  8. options: Record<string, string>;
  9. required?: boolean;
  10. autocomplete?: string;
  11. }>(),
  12. {
  13. required: false,
  14. autocomplete: "off"
  15. }
  16. );
  17. const value = defineModel<any>();
  18. </script>
  19. <template>
  20. <Input v-model="value" :required="required" :autocomplete="autocomplete">
  21. <slot />
  22. <template #input>
  23. <select
  24. class="inpt__input"
  25. v-model="value"
  26. :required="required"
  27. :autocomplete="autocomplete"
  28. >
  29. <option
  30. v-for="(
  31. [optionValue, optionLabel], index
  32. ) in Object.entries(options)"
  33. :key="`select-option-${index}`"
  34. :value="optionValue"
  35. >
  36. {{ optionLabel }}
  37. </option>
  38. </select>
  39. </template>
  40. </Input>
  41. </template>