--- order: 5 title: zh-CN: 查询模式 - 不确定类目 en-US: Lookup-Patterns - Uncertain Category --- ## zh-CN [查询模式: 不确定类目](https://ant.design/docs/spec/reaction#Lookup-Patterns) 示例。 ## en-US Demonstration of [Lookup Patterns: Uncertain Category](https://ant.design/docs/spec/reaction#Lookup-Patterns). ```tsx import React, { useState, FC } from 'react'; import { Input, AutoComplete } from 'antd'; import { SelectProps } from 'antd/es/select'; function getRandomInt(max: number, min: number = 0) { return Math.floor(Math.random() * (max - min + 1)) + min; // eslint-disable-line no-mixed-operators } const searchResult = (query: string) => { return new Array(getRandomInt(5)) .join('.') .split('.') .map((item, idx) => { const category = `${query}${idx}`; return { value: category, label: (
Found {query} on{' '} {category} {getRandomInt(200, 100)} results
), }; }); }; const Complete: FC = () => { const [options, setOptions] = useState['options']>([]); const handleSearch = (value: string) => { setOptions(value ? searchResult(value) : []); }; const onSelect = (value: string) => { console.log('onSelect', value); }; return ( ); }; ReactDOM.render(, mountNode); ```