gpt4 book ai didi

javascript - Ant 设计错误 : "Form.create() getFieldDecorator is not a function"

转载 作者:数据小太阳 更新时间:2023-10-29 05:25:04 25 4
gpt4 key购买 nike

"antd": "^1.11.1",
"react": "^15.1.0",
"react-dom": "^15.1.0",

错误:未捕获类型错误:getFieldDecorator 不是函数

Ant 设计演示:https://ant.design/components/form/

import React, {Component} from 'react';
import { Form, Icon, Input, Button } from 'antd';
const FormItem = Form.Item;

const HorizontalLoginForm = Form.create()(React.createClass({
handleSubmit(e) {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
}
});
},
render() {
const { getFieldDecorator } = this.props.form;
return (
<Form inline onSubmit={this.handleSubmit}>
<FormItem>
{getFieldDecorator('userName', {
rules: [{ required: true, message: 'Please input your username!' }],
})(
<Input addonBefore={<Icon type="user" />} placeholder="Username" />
)}
</FormItem>
<FormItem>
{getFieldDecorator('password', {
rules: [{ required: true, message: 'Please input your Password!' }],
})(
<Input addonBefore={<Icon type="lock" />} type="password" placeholder="Password" />
)}
</FormItem>
<FormItem>
<Button type="primary" htmlType="submit">Log in</Button>
</FormItem>
</Form>
);
},
}));

export default HorizontalLoginForm;

最佳答案

.getFieldDecorator() antd@2.0引入

您可以在此处找到 1.x 文档 http://1x.ant.design

关于javascript - Ant 设计错误 : "Form.create() getFieldDecorator is not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40699848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com