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

82 lines
2.6 KiB
Markdown
Raw Normal View History

2015-10-21 17:53:38 +08:00
# 表单动画进出场
- order: 4
表单组合的进场与出场动画。
---
````jsx
import { QueueAnim, Button, Checkbox, Radio } from 'antd';
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() {
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>
2015-11-25 17:47:55 +08:00
<QueueAnim component="form" className="ant-form-horizontal" type="bottom" leaveReverse>
2015-10-23 22:37:42 +08:00
{this.state.show ? [
<div className="ant-form-item ant-form-item-compact" key="name">
2015-10-21 17:53:38 +08:00
<label htmlFor="userName" className="col-6" required>用户名:</label>
<div className="col-6">
<p className="ant-form-text">大眼萌 minion</p>
</div>
</div>,
<div className="ant-form-item" key="password">
2015-10-21 17:53:38 +08:00
<label htmlFor="password" className="col-6" required>密码:</label>
<div className="col-14">
<input className="ant-input" type="password" id="password" placeholder="请输入密码"/>
</div>
</div>,
<div className="ant-form-item ant-form-item-compact" key="sex">
<label className="col-6" required>您的性别:</label>
2015-10-21 17:53:38 +08:00
<div className="col-14">
<RadioGroup value="male">
<Radio value="male">男的</Radio>
<Radio value="female">女的</Radio>
</RadioGroup>
</div>
</div>,
<div className="ant-form-item" key="remark">
2015-10-21 17:53:38 +08:00
<label htmlFor="remark" className="col-6" required>备注:</label>
<div className="col-14">
<textarea className="ant-input" id="remark" placeholder="随便写"></textarea>
<p className="ant-form-explain">随便写点什么</p>
</div>
</div>,
<div className="ant-form-item ant-form-item-compact" key="checkbox">
2015-10-21 17:53:38 +08:00
<div className="col-14 col-offset-6">
<label>
<Checkbox />
同意
</label>
</div>
</div>,
<div className="row" key="btn">
2015-10-21 17:53:38 +08:00
<div className="col-16 col-offset-6">
<Button type="primary">确定</Button>
</div>
2015-10-23 22:37:42 +08:00
</div>
] : 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
````