警告:失败的值类型:在“选择”中将值“ isRequired”标记为必需,但其值是“未定义”

时间:2019-04-24 04:10:39

标签: reactjs antd

  

index.js:2178警告:值类型失败:在isRequired中将值Select标记为必需,但其值为undefined

     

index.js:2178警告:defaultValue类型失败:在isRequired中将defaultValue Select标记为必需,但是其值为undefined

反应16.7

<Form layout="inline">
   <Form.Item>
      {
           getFieldDecorator('select')(
                 <Select placeholder='choose' style={{ width: 100 }} onChange={this.selectPuzzle}>
                      {options}
                 </Select>
              )
       }
   </Form.Item>
</Form>

1 个答案:

答案 0 :(得分:0)

根据antd文档, 应该是

{
  getFieldDecorator("select", {
    rules: [{ required: true, message: "Your message" }]
  })(
    <Select
      placeholder="choose"
      style={{ width: 100 }}
      onChange={this.selectPuzzle}
    >
      {options}
    </Select>
  );
}

防御链接:https://ant.design/components/form/