zoukankan      html  css  js  c++  java
  • antd4.x Form组建改变

    // antd v3
    function Demo (props)(
      const { form } = props
      const { getFieldDecorator, getFieldsValue, setFieldsValue } = form
      return (
         <Form>
          <Form.Item>
            {getFieldDecorator('username', {
              rules: [{ required: true }],
            })(<Input />)}
          </Form.Item>
        </Form>
      )
    ); export default Form.create()(Demo);
    // antd v4
    function Demo (props)(
      const [form] = Form.useForm()
      const { getFieldDecorator, getFieldsValue, setFieldsValue } = form

      retunr (
        <Form>
          <Form.Item name="username" label="usesrname" rules={[{required: true}]}>
            <Input/>
          </Form.Item>
        </Form>
      )
    
    );
     
    export default Demo;

      antd4.x移除了 Form.create(),原本的 onFieldsChange 等方法移入 Form 中,通过 fields 对 Form 进行控制

  • 相关阅读:
    Java annotation
    子类 父类强转 HttpServlet service实现
    父类 子类 强转
    HttpServlet Service方法
    java go
    IO写 PrintWriter
    IO读 BufferedReader+FileReader
    Java NIO-3
    心跳包(HeartBeat)
    Git学习笔记(一)
  • 原文地址:https://www.cnblogs.com/Mr-Rshare/p/13803194.html
Copyright © 2011-2022 走看看