Skip to content

类型转换

vue
import { ref, defineProps, defineEmits } from 'vue';
import {
  Listbox,
  ListboxButton,
  ListboxLabel,
  ListboxOption,
  ListboxOptions,
} from '@headlessui/vue';
import { CheckIcon, ChevronUpDownIcon } from '@heroicons/vue/20/solid';

export class SelectItem {
  Id: number = 0;
  Name: string = '';
}

const props = defineProps({
  items: {
    type: Array as () => SelectItem[],
    required: true,
  },
});

const emit = defineEmits(['select-event']);

const selected = ref<SelectItem>(props.items[0]);

const select = () => {
  emit('select-event', selected.value);
};
</script>