Browse Source

🎬 Add example for Select ``optionLabelProp` prop, #16709

pull/16737/head
afc163 6 years ago
parent
commit
3c22f86823
No known key found for this signature in database GPG Key ID: 738F973FCE5C6B48
  1. 4
      components/select/demo/multiple.md
  2. 49
      components/select/demo/option-label-prop.md
  3. 2
      components/select/index.en-US.md
  4. 2
      components/select/index.zh-CN.md

4
components/select/demo/multiple.md

@ -7,11 +7,11 @@ title:
## zh-CN
多选,从已有条目中选择(scroll the menu)
多选,从已有条目中选择
## en-US
Multiple selection, selecting from existing items (scroll the menu).
Multiple selection, selecting from existing items.
```jsx
import { Select } from 'antd';

49
components/select/demo/option-label-prop.md

@ -0,0 +1,49 @@
---
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">
🇨🇳 China (中国)
</Option>
<Option value="usa" label="USA">
🇺🇸 USA (美国)
</Option>
<Option value="japan" label="Japan">
🇯🇵 Japan (日本)
</Option>
<Option value="koean" label="Koean">
🇰🇷 Koean (韩国)
</Option>
</Select>,
mountNode,
);
```

2
components/select/index.en-US.md

@ -43,7 +43,7 @@ Select component to select value from options.
| mode | Set mode of Select | 'default' \| 'multiple' \| 'tags' | 'default' |
| notFoundContent | Specify content to show when no result matches.. | string | 'Not Found' |
| optionFilterProp | Which prop value of option will be used for filter if filterOption is true | string | value |
| optionLabelProp | Which prop value of option will render as content of select. | string | `value` for `combobox`, `children` for other modes |
| optionLabelProp | Which prop value of option will render as content of select. [Example](https://codesandbox.io/s/antd-reproduction-template-tk678) | string | `value` for `combobox`, `children` for other modes |
| placeholder | Placeholder of select | string\|ReactNode | - |
| showArrow | Whether to show the drop-down arrow | boolean | true |
| showSearch | Whether show search input in single mode. | boolean | false |

2
components/select/index.zh-CN.md

@ -43,7 +43,7 @@ title: Select
| maxTagPlaceholder | 隐藏 tag 时显示的内容 | ReactNode/function(omittedValues) | - |
| mode | 设置 Select 的模式为多选或标签 | 'multiple' \| 'tags' | - |
| notFoundContent | 当下拉列表为空时显示的内容 | string | 'Not Found' |
| optionFilterProp | 搜索时过滤对应的 option 属性,如设置为 children 表示对内嵌内容进行搜索 | string | value |
| optionFilterProp | 搜索时过滤对应的 option 属性,如设置为 children 表示对内嵌内容进行搜索。[示例](https://codesandbox.io/s/antd-reproduction-template-tk678) | string | value |
| optionLabelProp | 回填到选择框的 Option 的属性值,默认是 Option 的子元素。比如在子元素需要高亮效果时,此值可以设为 `value`。 | string | `children` (combobox 模式下为 `value`) |
| placeholder | 选择框默认文字 | string | - |
| showArrow | 是否显示下拉小箭头 | boolean | true |

Loading…
Cancel
Save