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
		]
	}
}
posted @ 2025-04-14 16:02  Felix_Openmind  阅读(185)  评论(0)    收藏  举报
*{cursor: url(https://files-cdn.cnblogs.com/files/morango/fish-cursor.ico),auto;}