zoukankan      html  css  js  c++  java
  • Antd版本V3-->V4迁移问题:初始化调整

    本文介绍个常见问题

    Antd的V3---V4版本迁移问题,将 initialValue 从字段中移到 Form 中。以避免同名字段设置 initialValue 的冲突问题:

    // antd v3
    const Demo = ({ form: { getFieldDecorator } }) => (
      <Form>
        <Form.Item>
          {getFieldDecorator('username', {
            rules: [{ required: true }],
            initialValue: 'Bamboo',
          })(<Input />)}
        </Form.Item>
      </Form>
    );
    
    const WrappedDemo = Form.create()(Demo);

    改成:

    // antd v4
    const Demo = () => (
      <Form initialValues={{ username: 'Bamboo' }}>
        <Form.Item name="username" rules={[{ required: true }]}>
          <Input />
        </Form.Item>
      </Form>
    );

    在 v3 版本中,修改未操作的字段 initialValue 会同步更新字段值,这是一个 BUG。但是由于被长期作为一个 feature 使用,因而我们一直没有修复。在 v4 中,该 BUG 已被修复。initialValue 只有在初始化以及重置表单时生效。

    .

  • 相关阅读:
    lightoj1140_数位dp
    lightoj1057_状压dp
    lightoj1068_数位dp
    lightoj1018_状压dp
    lightoj1217_简单dp
    lightoj1119_简单状压dp
    lightoj1037_状压dp
    lightoj1110_LCS并输出
    图论算法----最短路
    poj1182 食物链
  • 原文地址:https://www.cnblogs.com/jianxian/p/12616297.html
Copyright © 2011-2022 走看看