This commit is contained in:
xiaojunnuo
2024-09-30 18:00:51 +08:00
parent 8d42273665
commit 17a9beb514
12 changed files with 149 additions and 22 deletions
@@ -22,6 +22,19 @@ const getOptions = async () => {
});
};
const filterOption = (input: string, option: any) => {
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 || String(option.value).toLowerCase().indexOf(input.toLowerCase());
};
let isFirst = true;
async function onClick() {
if (!isFirst) {
return;
}
isFirst = false;
optionsRef.value = await getOptions();
}
watch(
() => {
const values = [];
@@ -35,13 +48,20 @@ watch(
},
async () => {
optionsRef.value = await getOptions();
},
{ immediate: true }
}
);
</script>
<template>
<a-select class="remote-select" :options="optionsRef" :value="value" @update:value="emit('update:value', $event)" />
<a-select
class="remote-select"
show-search
:filter-option="filterOption"
:options="optionsRef"
:value="value"
@click="onClick"
@update:value="emit('update:value', $event)"
/>
</template>
<style lang="less"></style>