选项支持搜索
This commit is contained in:
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user