ElDict.vue 637 B

12345678910111213141516171819202122232425262728
  1. <script lang="ts" setup>
  2. import { getDict } from '@/utils/dict'
  3. interface Props {
  4. modelValue: any
  5. type: string
  6. }
  7. const props = defineProps<Props>()
  8. const emits = defineEmits(['update:modelValue'])
  9. const modelValue = computed({
  10. get: () => props.modelValue,
  11. set: value => emits('update:modelValue', value)
  12. })
  13. const options = ref<any>([])
  14. getDict(props.type).then(res => {
  15. options.value = res
  16. })
  17. </script>
  18. <template>
  19. <el-select v-model="modelValue">
  20. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
  21. </el-select>
  22. </template>
  23. <style lang="scss" scoped></style>