mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 21:19:37 +08:00
41 lines
761 B
TypeScript
41 lines
761 B
TypeScript
import { Select } from 'antd';
|
|
import React from 'react';
|
|
|
|
const onChange = (value: string) => {
|
|
console.log(`selected ${value}`);
|
|
};
|
|
|
|
const onSearch = (value: string) => {
|
|
console.log('search:', value);
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<Select
|
|
showSearch
|
|
style={{ width: 160 }}
|
|
placeholder="Select a person"
|
|
optionFilterProp="children"
|
|
onChange={onChange}
|
|
onSearch={onSearch}
|
|
filterOption={(input, option) =>
|
|
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
|
|
}
|
|
options={[
|
|
{
|
|
value: 'jack',
|
|
label: 'Jack',
|
|
},
|
|
{
|
|
value: 'lucy',
|
|
label: 'Lucy',
|
|
},
|
|
{
|
|
value: 'tom',
|
|
label: 'Tom',
|
|
},
|
|
]}
|
|
/>
|
|
);
|
|
|
|
export default App;
|