a-select中filterOption前端实现过滤
<a-select
v-model:value="record.positions"
placeholder="请选择"
show-search
:filterOption="filterOption"
@change="(value, option) => onSelect(value, option, record)">
<a-select-option v-for="opt in jobLevelOpts" :key="opt.value">
{{ opt.label }}
</a-select-option>
</a-select>
const filterOption = (input, option) => {
const label = jobLevelOpts.value.find(opt => opt.value === option.key)?.label
return label && label.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
const jobLevelOpts = ref([])
const initOpt = async () => {
const res = await getDicitemList({ parentCode: 'job_type' })
if (isResponseSuccess(res)) {
let resOpts = res.data.data.map(item => {
return {
label: item.itemName,
value: item.code
}
})
jobLevelOpts.value = [
...jobLevelOpts.value,
...resOpts
]
}
}
学而不思则罔,思而不学则殆!

浙公网安备 33010602011771号