mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-21 21:28:09 +08:00
a5d308b408
* feat: select filter support sort param * docs: update demo to fix lint --------- Co-authored-by: 闲夕 <shizexian.szx@antgroup.com>
55 lines
999 B
TypeScript
55 lines
999 B
TypeScript
import React from 'react';
|
|
import { Select, Space } from 'antd';
|
|
|
|
const handleChange = (value: string[]) => {
|
|
console.log(`selected ${value}`);
|
|
};
|
|
|
|
const options = [
|
|
{
|
|
label: 'China',
|
|
value: 'china',
|
|
emoji: '🇨🇳',
|
|
desc: 'China (中国)',
|
|
},
|
|
{
|
|
label: 'USA',
|
|
value: 'usa',
|
|
emoji: '🇺🇸',
|
|
desc: 'USA (美国)',
|
|
},
|
|
{
|
|
label: 'Japan',
|
|
value: 'japan',
|
|
emoji: '🇯🇵',
|
|
desc: 'Japan (日本)',
|
|
},
|
|
{
|
|
label: 'Korea',
|
|
value: 'korea',
|
|
emoji: '🇰🇷',
|
|
desc: 'Korea (韩国)',
|
|
},
|
|
];
|
|
|
|
const App: React.FC = () => (
|
|
<Select
|
|
mode="multiple"
|
|
style={{ width: '100%' }}
|
|
placeholder="select one country"
|
|
defaultValue={['china']}
|
|
onChange={handleChange}
|
|
options={options}
|
|
optionRender={(option) => (
|
|
<Space>
|
|
<span role="img" aria-label={option.data.label}>
|
|
{option.data.emoji}
|
|
</span>
|
|
{option.data.desc}
|
|
</Space>
|
|
)}
|
|
/>
|
|
);
|
|
|
|
export default App;
|