Ant Design使用了getFieldDecorator正确的使用姿势

 Select类型:
{getFieldDecorator('sceneCategoryId', {
                  rules: [{ required: true, message: '请选择场景类型' }],
                  initialValue: sceneCategoryId
                })(
                  <Select style={{  '100%' }} onChange={this.typeSelect} placeholder='请选择场景类型'
                    className='selectStyle'
                    dropdownClassName='mySelect'>
                    {this.state.selectData.map((item, i) => {
                      return (<Option key={item.SCENE_CATEGORY_ID} value={item.SCENE_CATEGORY_ID}>{item.SCENE_CATEGORY_NAME}</Option>)
                    })}
                  </Select>
                )}
 
Input类型:
{getFieldDecorator('sceneName', {
                  rules: [{ required: true, message: '请输入场景名称' },
                  {
                    whitespace: true,
                    message: '不能输入空格',
                  }
                    // ,
                    // {
                    //   validator: this.validateToSceneName
                    // }
                  ],
                  initialValue: sceneName
                })(<Input onChange={this.sceneNameChange} placeholder='请输入场景名称' />)}
Textarea类型和Input类型一样
      
 {getFieldDecorator('sceneDsc', {
                  rules: [{ required: true, message: '请输入场景描述' },
                  {
                    whitespace: true,
                    message: '不能输入空格',
                  }
                  ],
                  initialValue: sceneDsc
                })(<TextArea style={{ height: '100px' }} rows={4} onChange={this.sceneDscChange} placeholder='请输入场景描述' />)}
原文地址:https://www.cnblogs.com/snowhite/p/14487602.html