码迷,mamicode.com
首页 > 其他好文 > 详细

5-3 使用antDesign的form组件

时间:2019-07-19 18:36:18      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:技术   type   NPU   wrap   name   decorator   ant   ldd   got   

技术图片

 

import { Form, Icon, Input, Button, Checkbox } from ‘antd‘;

class NormalLoginForm extends React.Component {
  handleSubmit = e => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        console.log(‘Received values of form: ‘, values);
      }
    });
  };

  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <Form onSubmit={this.handleSubmit} className="login-form">
        <Form.Item>
          {getFieldDecorator(‘username‘, {
            rules: [{ required: true, message: ‘Please input your username!‘ }],
          })(
            <Input
              prefix={<Icon type="user" style={{ color: ‘rgba(0,0,0,.25)‘ }} />}
              placeholder="Username"
            />,
          )}
        </Form.Item>
        <Form.Item>
          {getFieldDecorator(‘password‘, {
            rules: [{ required: true, message: ‘Please input your Password!‘ }],
          })(
            <Input
              prefix={<Icon type="lock" style={{ color: ‘rgba(0,0,0,.25)‘ }} />}
              type="password"
              placeholder="Password"
            />,
          )}
        </Form.Item>
        <Form.Item>
          {getFieldDecorator(‘remember‘, {
            valuePropName: ‘checked‘,
            initialValue: true,
          })(<Checkbox>Remember me</Checkbox>)}
          <a className="login-form-forgot" href="">
            Forgot password
          </a>
          <Button type="primary" htmlType="submit" className="login-form-button">
            Log in
          </Button>
          Or <a href="">register now!</a>
        </Form.Item>
      </Form>
    );
  }
}

const WrappedNormalLoginForm = Form.create({ name: ‘normal_login‘ })(NormalLoginForm);

ReactDOM.render(<WrappedNormalLoginForm />, mountNode);

 

5-3 使用antDesign的form组件

标签:技术   type   NPU   wrap   name   decorator   ant   ldd   got   

原文地址:https://www.cnblogs.com/wskb/p/11214942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!