|
|
|
---
|
|
|
|
order: 5
|
|
|
|
title: 表单组合
|
|
|
|
---
|
|
|
|
|
|
|
|
集中营,展示和表单相关的其他 ant-design 组件。
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { Form, Select, InputNumber, DatePicker, TimePicker, Switch, Radio,
|
|
|
|
Cascader, Slider, Button, Col, Upload, Icon } from 'antd';
|
|
|
|
const FormItem = Form.Item;
|
|
|
|
const Option = Select.Option;
|
|
|
|
const RadioButton = Radio.Button;
|
|
|
|
const RadioGroup = Radio.Group;
|
|
|
|
|
|
|
|
const areaData = [{
|
|
|
|
value: 'shanghai',
|
|
|
|
label: '上海',
|
|
|
|
children: [{
|
|
|
|
value: 'shanghaishi',
|
|
|
|
label: '上海市',
|
|
|
|
children: [{
|
|
|
|
value: 'pudongxinqu',
|
|
|
|
label: '浦东新区',
|
|
|
|
}],
|
|
|
|
}],
|
|
|
|
}];
|
|
|
|
|
|
|
|
let Demo = React.createClass({
|
|
|
|
handleSubmit(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
console.log('收到表单值:', this.props.form.getFieldsValue());
|
|
|
|
},
|
|
|
|
|
|
|
|
normFile(e) {
|
|
|
|
if (Array.isArray(e)) {
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
return e && e.fileList;
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const { getFieldProps } = this.props.form;
|
|
|
|
return (
|
|
|
|
<Form horizontal onSubmit={this.handleSubmit} >
|
|
|
|
<FormItem
|
|
|
|
label="InputNumber 数字输入框:"
|
|
|
|
labelCol={{ span: 8 }}
|
|
|
|
wrapperCol={{ span: 10 }}>
|
|
|
|
<InputNumber min={1} max={10} style={{ width: 100 }}
|
|
|
|
{...getFieldProps('inputNumber', { initialValue: 3 })} />
|
|
|
|
<span className="ant-form-text"> 台机器</span>
|
|
|
|
</FormItem>
|
|
|
|
|
|
|
|
<FormItem
|
|
|
|
label="我是标题:"
|
|
|
|
labelCol={{ span: 8 }}
|
|
|
|
wrapperCol={{ span: 10 }}>
|
|
|
|
<p className="ant-form-text" id="static" name="static">唧唧复唧唧木兰当户织呀</p>
|
|
|
|
<p className="ant-form-text">
|
|
|
|
<a href="#">链接文字</a>
|
|
|
|
</p>
|
|
|
|
</FormItem>
|
|
|
|
|
|
|
|
<FormItem
|
|
|
|
label="Switch 开关:"
|
|
|
|
labelCol={{ span: 8 }}
|
|
|
|
wrapperCol={{ span: 10 }}
|
|
|
|
required>
|
|
|
|
<Switch {...getFieldProps('switch', { valuePropName: 'checked' })} />
|
|
|
|
</FormItem>
|
|
|
|
|
|
|
|
<FormItem
|
|
|
|
label="Slider 滑动输入条:"
|
|
|
|
labelCol={{ span: 8 }}
|
|
|
|
wrapperCol={{ span: 10 }}
|
|
|
|
required>
|
|
|
|
<Slider marks={['A', 'B', 'C', 'D', 'E', 'F', 'G']} {...getFieldProps('slider')} />
|
|
|
|
</FormItem>
|
|
|
|
|
|
|
|
<FormItem
|
|
|
|
label="Select 选择器:"
|
|
|
|
labelCol={{ span: 8 }}
|
|
|
|
wrapperCol={{ span: 16 }}
|
|
|
|
required>
|
|
|
|
<Select style={{ width: 200 }}
|
|
|
|
{...getFieldProps('select')}>
|
|
|
|
<Option value="jack">jack</Option>
|
|
|
|
<Option value="lucy">lucy</Option>
|
|
|
|
<Option value="disabled" disabled>disabled</Option>
|
|
|
|
<Option value="yiminghe">yiminghe</Option>
|
|
|
|
</Select>
|
|
|
|
</FormItem>
|
|
|
|
|
|
|
|
|