ant-design/components/queue-anim/demo/form.md

66 lines
1.8 KiB
Markdown
Raw Normal View History

2015-10-21 17:53:38 +08:00
# 表单动画进出场
- order: 4
表单组合的进场与出场动画。
---
````jsx
2016-03-29 20:29:41 +08:00
import { QueueAnim, Button, Radio, Input, Form, Row, Col } from 'antd';
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
2015-10-21 17:53:38 +08:00
const Test = React.createClass({
2015-10-21 17:53:38 +08:00
getInitialState() {
return {
2015-10-23 22:37:42 +08:00
show: true
};
2015-10-21 17:53:38 +08:00
},
onClick() {
this.setState({
2015-10-23 22:37:42 +08:00
show: !this.state.show
});
2015-10-21 17:53:38 +08:00
},
render() {
2016-03-29 20:29:41 +08:00
const formItemLayout = {
labelCol: { span: 6 },
wrapperCol: { span: 14 },
};
2015-10-21 17:53:38 +08:00
return (
<div>
2015-10-23 22:37:42 +08:00
<p className="buttons">
2015-10-21 17:53:38 +08:00
<Button type="primary" onClick={this.onClick}>切换</Button>
2015-10-23 22:37:42 +08:00
</p>
2016-03-29 20:29:41 +08:00
<QueueAnim component={Form} className="ant-form ant-form-horizontal" type="bottom" leaveReverse>
2015-10-23 22:37:42 +08:00
{this.state.show ? [
2016-03-29 20:29:41 +08:00
<FormItem key="item1" {...formItemLayout} label="用户名:">
<p className="ant-form-text">大眼萌 minion</p>
</FormItem>,
<FormItem key="item2" {...formItemLayout} label="密码:">
<Input type="password" placeholder="请输入密码" />
</FormItem>,
<FormItem key="item3" {...formItemLayout} label="您的性别:">
<RadioGroup>
<Radio value="male">男的</Radio>
<Radio value="female">女的</Radio>
</RadioGroup>
</FormItem>,
<FormItem key="item4" {...formItemLayout} label="备注:">
<Input type="textarea" placeholder="随便写" />
</FormItem>,
<Row key="submit">
<Col span="16" offset="6">
<Button type="primary" htmlType="submit">确定</Button>
</Col>
</Row>,
2015-10-23 22:37:42 +08:00
] : null}
2015-10-21 17:53:38 +08:00
</QueueAnim>
</div>
2015-10-23 22:37:42 +08:00
);
2015-10-21 17:53:38 +08:00
}
});
ReactDOM.render(<Test />, mountNode);
2015-10-21 17:53:38 +08:00
````