鍍金池/ 問答/HTML/ Ant Design 3.x 按條件動(dòng)態(tài)渲染表單項(xiàng)時(shí),如何在重新渲染時(shí)將值恢復(fù)到

Ant Design 3.x 按條件動(dòng)態(tài)渲染表單項(xiàng)時(shí),如何在重新渲染時(shí)將值恢復(fù)到控件上?

3.0 版本之后增加了 fieldName 相同的情況下動(dòng)態(tài)變更表單項(xiàng)的緩存值,但是通過 getFieldsValue 能獲取緩存的值,卻無法渲染到到包裝的組件上,也不能用 initialValue 設(shè)置,因?yàn)樵谟?getFieldDecorator 包裝之前,是獲取不到值的。

        if(visible)
        {
            return (
                <Form.Item label={label} hasFeedback={feedback} {...formLayout} help={help} extra={extra}>
                    { form.getFieldDecorator(name, options)(children) }
                </Form.Item>
            );
        }
回答
編輯回答
陌上花

class CustomizedForm extends React.Component {}

CustomizedForm = Form.create({})(CustomizedForm);

https://ant.design/components...

2018年7月28日 09:18
編輯回答
紓惘

那你用setFieldsValue
如果要讓initialValue生效,可以執(zhí)行resetFields。

2017年5月13日 17:57