选项支持搜索

This commit is contained in:
lq
2025-09-12 17:48:46 +08:00
parent b3d1a4789d
commit 2b98615d2a

View File

@ -13,6 +13,7 @@
showArrow
:maxTagCount="maxTagCount"
@change="handleChange"
:filterOption="allowSearch ? filterOption : undefined"
>
<Option v-for="(item, index) in validOptions" :key="index" :value="item.value" :label="item.label">
<div class="flex items-center">
@ -105,6 +106,17 @@ const handleChange = (value) => {
selectedValues.value = value;
emits('change', value);
};
// 搜索过滤函数
const filterOption = (input, option) => {
// 确保 input 和 option.label 都存在且为字符串
if (!input || !option || !option.label) {
return false;
}
// 不区分大小写的模糊搜索
return option.label.toString().toLowerCase().includes(input.toLowerCase());
};
</script>
<style scoped>