2015-07-07 11:25:16 +08:00
|
|
|
|
# 行内排列的表单
|
2015-06-15 20:24:01 +08:00
|
|
|
|
|
2015-07-07 23:45:46 +08:00
|
|
|
|
- order: 1
|
2015-06-15 20:24:01 +08:00
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2015-07-20 20:35:48 +08:00
|
|
|
|
````jsx
|
2015-10-09 15:44:10 +08:00
|
|
|
|
var Form = antd.Form;
|
2015-07-20 20:35:48 +08:00
|
|
|
|
var Checkbox = antd.Checkbox;
|
2015-10-08 15:13:04 +08:00
|
|
|
|
var Button = antd.Button;
|
2015-10-27 19:23:45 +08:00
|
|
|
|
var message = antd.message;
|
2015-07-20 20:35:48 +08:00
|
|
|
|
|
2015-10-25 11:35:03 +08:00
|
|
|
|
var Demo = React.createClass({
|
|
|
|
|
mixins: [Form.ValueMixin],
|
|
|
|
|
|
|
|
|
|
getInitialState() {
|
|
|
|
|
return {
|
|
|
|
|
formData: {
|
|
|
|
|
userName: undefined,
|
|
|
|
|
password: undefined,
|
|
|
|
|
agreement: undefined,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleSubmit(e) {
|
|
|
|
|
e.preventDefault();
|
2015-10-27 19:23:45 +08:00
|
|
|
|
message.success("收到表单值~~~ :" + JSON.stringify(this.state.formData, function(k, v) {
|
|
|
|
|
if (typeof v === 'undefined') {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
return v;
|
|
|
|
|
}));
|
2015-10-25 11:35:03 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
var formData = this.state.formData;
|
|
|
|
|
return (
|
|
|
|
|
<Form inline onSubmit={this.handleSubmit}>
|
|
|
|
|
<Form.Item
|
2015-10-27 19:23:45 +08:00
|
|
|
|
id="userName"
|
2015-10-25 11:35:03 +08:00
|
|
|
|
label="账户:">
|
|
|
|
|
<Form.Input type="text" placeholder="请输入账户名" id="userName" name="userName" onChange={this.setValue.bind(this, 'userName')} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item
|
2015-10-27 19:23:45 +08:00
|
|
|
|
id="password"
|
2015-10-25 11:35:03 +08:00
|
|
|
|
label="密码:">
|
|
|
|
|
<Form.Input type="password" placeholder="请输入密码" id="password" name="password" onChange={this.setValue.bind(this, 'password')} />
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Item>
|
|
|
|
|
<label className="ant-checkbox-inline">
|
|
|
|
|
<Checkbox name="agreement" value={formData.agreement} onChange={this.setValue.bind(this, 'agreement')} /> 记住我
|
|
|
|
|
</label>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Form.Input type="submit" className="ant-btn ant-btn-primary" defaultValue="登 录" />
|
|
|
|
|
</Form>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ReactDOM.render(<Demo />, document.getElementById('components-form-demo-inline-form'));
|
2015-06-15 20:24:01 +08:00
|
|
|
|
````
|