React getFieldDecorator initialValue第一次设置初始值之后初始值再改变失效

getFieldDecorator initialValue第一次设置初始值之后初始值再改变失效

{
    
    getFieldDecorator('vehicleHouse', {
    
    
                        initialValue: LandConditionsForm.vehicleHouse,
                        rules: [
                          {
    
    
                            // pattern: reg,
                            required: false,
                          },
                          (rule, value, callback, source, options) => {
    
    
                        
                          },
                        ],
                      })(<Input disabled={
    
    cantEdit}  onBlur={
    
    ()=>autoSaveStatus?this.checkDetailTable(false):null}/>)}

原因分析:

initialValue仅限挂载后值才会对应改变,state改变只触发render,form并没有重置

解决方案:

更新数据时使用 form.resetFields();form重置即可

ck
var foo = ‘bar’;

const {
    
     form } = this.props;
    form.resetFields();

猜你喜欢

转载自blog.csdn.net/m0_55588706/article/details/120784513