我有两个页面 addressForm.js 和 index.js 。在 addressForm.js 页面中,为Form编写了代码。示例代码如下所示。
['0', '1', '1', '0', '1']
在 index.js 页中编写了表单的功能(单击 Submit (提交)按钮时会发生什么)。示例代码:
<Col >
<div style={{'height': '45px','display':'flex'}}>
<label style={{'color': '#f5222d', 'paddingTop': '10px','fontFamily': 'SimSun'}}>*</label>
<label style={{'width':'74px','paddingTop':'8px'}}>Customer Name:</label>
<FormItem >
{getFieldDecorator('Name', {
initialValue: '',
rules: [{
required: true,
message: (
<Tooltip
visible={true} placement="topRight"
title="Please Input Customer Name"
/>
),
}],
})(
<Input placeholder="Customer Name" style={{'width':'164px'}} onChange={(e)=>{e.preventDefault(); e.stopPropagation();
this.handleChange(0,e, 'Name')}}/>
)}
</FormItem>
</div>
</Col>
问题是验证不起作用(即验证检查未完成,并且出现此错误)。
我应该在index.js页面中导入任何内容以避免该错误吗?
答案 0 :(得分:1)
您可以通过尝试以下代码来解决此问题:
class Devices extends React.Component {
.................
}
Devices = Form.create({})(Devices);
export default Devices;
答案 1 :(得分:0)
道具中的某些内容未正确传递或定义,从而导致TypeError。看来您可能需要将props显式地传递到handleOk函数中-尽管提供的代码片段很难分辨。
答案 2 :(得分:0)
在documentation中,form
应该用Form.create
装饰。
如果表单已由Form.create装饰,则它具有this.props.form属性。
class CustomizedForm extends React.Component {}
CustomizedForm = Form.create({})(CustomizedForm);