antd 表单绑定Input和Select报错

问题描述

antd表单绑定select组件,

问题出现的环境背景及自己尝试过哪些方法

clipboard.png

相关代码

// 请把代码文本粘贴到下方(请勿用图片代替代码)

                    <FormItem label={label}
                              key={fileId}
                              {...formItemLayout}>
                        {
                            getFieldDecorator([fileId], {
                                initialValue
                            })(
                                <Select placeholder={placeholder}
                                        showSearch
                                        allowClear>
                                    {this.getOptionList(item.optionList)}
                                </Select>
                            )
                        }
                    </FormItem>
                    

clipboard.png

你期待的结果是什么?实际看到的错误信息又是什么?

阅读 2.2k
1 个回答

[fileId]这直接写 fileId 这个位置放String,而不是Array

 <FormItem 
  label={label}
  key={fileId}
  {...formItemLayout}>
    {
        getFieldDecorator(fileId)(
            <Select placeholder={placeholder}
                    showSearch
                    allowClear>
                {this.getOptionList(item.optionList)}
            </Select>
        )
    }
</FormItem>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题