添加 dic 组件,select 和 value text
This commit is contained in:
13
admin-web/src/components/Dictionary/DictionarySelect.d.ts
vendored
Normal file
13
admin-web/src/components/Dictionary/DictionarySelect.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import * as React from 'react';
|
||||
import { Select } from 'antd';
|
||||
|
||||
export interface DictionaryObject {
|
||||
text?: string;
|
||||
value?: string | number | boolean;
|
||||
}
|
||||
|
||||
export interface IDictionarySelectProps extends Select {
|
||||
list?: DictionaryObject[];
|
||||
}
|
||||
|
||||
export default class DictionarySelectD extends React.Component<IDictionarySelectProps, any> {}
|
||||
20
admin-web/src/components/Dictionary/DictionarySelect.js
Normal file
20
admin-web/src/components/Dictionary/DictionarySelect.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { Select } from 'antd';
|
||||
|
||||
export default class DictionarySelect extends PureComponent {
|
||||
renderOptions() {
|
||||
const { list } = this.props;
|
||||
return list.map(item => {
|
||||
return (
|
||||
<Select.Option key={item.value} value={item.value}>
|
||||
{item.text}
|
||||
</Select.Option>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const options = this.renderOptions();
|
||||
return <Select {...this.props}>{options}</Select>;
|
||||
}
|
||||
}
|
||||
24
admin-web/src/components/Dictionary/DictionarySelect.md
Normal file
24
admin-web/src/components/Dictionary/DictionarySelect.md
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: DictionarySelect
|
||||
subtitle: 描述列表
|
||||
---
|
||||
|
||||
次组件跟使用 Antd extends Select,使用方法跟 Select 一样
|
||||
|
||||
## API
|
||||
|
||||
### DescriptionList
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|----------|------------------------------------------|-------------|-------|
|
||||
| list | 数据列表 | DictionObject[] | [] |
|
||||
|
||||
### DictionObject
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|----------|------------------------------------------|-------------|-------|
|
||||
| text | 显示的文字 | string | - |
|
||||
| value | 选择后的值 | string number boolean | - |
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user