关于 getFieldDecorator is not defined
来源:11-2 Ant Design 框架的引入
到处用
2017-08-28
报错:getFieldDecorator is not defined ,根据要求我也使用TradeManagement = Form.create({})(TradeManagement);进行处理了,为什么还是报错。
class TradeManagement extends React.Component {
//初始化
constructor(props) {
super(props);
}
render() {
const {userList, dataSource, dataSourceXianmu} = this.state;
const columns = [{
title: '姓名',
dataIndex: 'aname',
key: 'aname',
// render: text => <a href="#">{text}</a>
}, {
title: '电话',
dataIndex: 'atel',
key: 'atel',
}];
return (
<HomeLayout title="用户列表">
<Form layout="inline">
<FormItem>
{/*数据变化保存在 state 里,然后提交数据时候,将state数据作为参数*/}
<Input onChange={(e) => this.handleChange(e)}
prefix={<Icon type="search" style={{fontSize: 13}}/>} placeholder="手机号码"/>
</FormItem>
<FormItem>
<Button >搜索</Button>
</FormItem>
</Form>
<Table onRowDoubleClick={this.showCurRowMessage} columns={columns} dataSource={userList}
loading={this.state.loading}
style={{paddingTop: '10px'}}/>
<Modal visible={this.state.visiblechuzhika} title="储值卡">
<Form>
<FormItem label="服务项目">
{getFieldDecorator('xiangmu', {
rules: [{required: true, message: '请选择服务项目'}],
})(
<AutoComplete
dataSource={dsx}
placeholder="选择服务项目"
filterOption={(inputValue, option) => option.props.children.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1}
/>
)}
</FormItem>
</Form>
</Modal>
</HomeLayout>
);
}
}
TradeManagement = Form.create({})(TradeManagement);
export default TradeManagement;
1回答
-
你在render()方法后面要加上
let { getFieldDecorator } = this.props.form;
来定义getFieldDecorator
212017-08-28
相似问题