2019-05-22 19:33:03 +08:00
|
|
|
---
|
|
|
|
order: 4
|
|
|
|
title:
|
|
|
|
zh-CN: 定制回填内容
|
|
|
|
en-US: Custom selection render
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
使用 `optionLabelProp` 指定回填到选择框的 `Option` 属性。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Spacified the prop name of Option which will be rendered in select box.
|
|
|
|
|
|
|
|
```jsx
|
|
|
|
import { Select } from 'antd';
|
|
|
|
|
|
|
|
const { Option } = Select;
|
|
|
|
|
|
|
|
function handleChange(value) {
|
|
|
|
console.log(`selected ${value}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
<Select
|
|
|
|
mode="multiple"
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
placeholder="select one country"
|
|
|
|
defaultValue={['china']}
|
|
|
|
onChange={handleChange}
|
|
|
|
optionLabelProp="label"
|
|
|
|
>
|
|
|
|
<Option value="china" label="China">
|
2019-05-22 19:41:53 +08:00
|
|
|
<span role="img" aria-label="China">
|
2019-10-05 17:35:49 +08:00
|
|
|
🇨🇳
|
2019-05-22 19:41:53 +08:00
|
|
|
</span>
|
|
|
|
China (中国)
|
2019-05-22 19:33:03 +08:00
|
|
|
</Option>
|
|
|
|
<Option value="usa" label="USA">
|
2019-05-22 19:41:53 +08:00
|
|
|
<span role="img" aria-label="USA">
|
2019-10-05 17:35:49 +08:00
|
|
|
🇺🇸
|
2019-05-22 19:41:53 +08:00
|
|
|
</span>
|
|
|
|
USA (美国)
|
2019-05-22 19:33:03 +08:00
|
|
|
</Option>
|
|
|
|
<Option value="japan" label="Japan">
|
2019-09-02 15:47:36 +08:00
|
|
|
<span role="img" aria-label="Japan">
|
2019-10-05 17:35:49 +08:00
|
|
|
🇯🇵
|
2019-05-22 19:41:53 +08:00
|
|
|
</span>
|
|
|
|
Japan (日本)
|
2019-05-22 19:33:03 +08:00
|
|
|
</Option>
|
2019-09-02 15:47:36 +08:00
|
|
|
<Option value="korea" label="Korea">
|
|
|
|
<span role="img" aria-label="Korea">
|
2019-10-05 17:35:49 +08:00
|
|
|
🇰🇷
|
2019-05-22 19:41:53 +08:00
|
|
|
</span>
|
2019-09-02 15:47:36 +08:00
|
|
|
Korea (韩国)
|
2019-05-22 19:33:03 +08:00
|
|
|
</Option>
|
|
|
|
</Select>,
|
|
|
|
mountNode,
|
|
|
|
);
|
|
|
|
```
|