<script setup> /** * @description: 下拉单选控件(自定义数据源) */ import { computed } from 'vue'; const props = defineProps({ modelValue: { type: String, default: undefined, }, query: { type: Object, default: () => ({}), }, }); const emit = defineEmits(['update:modelValue']); const filterOption = (input, option) => { console.log(input, option); return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0; }; const handleChange = (e) => { emit('update:modelValue', e); }; </script> <template> <a-select allow-clear show-search v-bind="$attrs" :value="modelValue" :filter-option="filterOption" @change="handleChange"> <a-select-option v-for="(option, index) in props.query.options" :key="index" :value="option.value">{{ option.label }}</a-select-option> </a-select> </template> <style lang="less" scoped></style> JavaScript 中 Number 类型的数据没有 toLowerCase 方法,会导致filterOption 方法报错