解决antd Cannot read property 'validate' of undefined
来源:互联网 发布:程序员 bug 编辑:程序博客网 时间:2024/06/06 05:53
问题描述:使用React+antd开发,本地使用新建表单Form的Input没什么问题,但是,打包到服务器上之后,在输入框输入值后报错,Cannot read property ‘validate’ of undefined。
问题原因:使用 Form.create()((props) => { 。。。。})
创建表单。
Form.create() 是不能这样这样直接新建表单Form的。
解决方案:建议新建一个组件,使用该组件来创建页面内的表单Form。
// 1.组件代码import React from 'react'import { Form } from 'antd'export const createForm = (statelessFunc) => { return Form.create()(React.createClass({ render() { return statelessFunc(this.props) } }));}
// 2.配置你的组件封装路径(你的组件配置方式)
// 3.引入及使用import { createForm } from 'enhanceUtil';const niceForm = createForm((props) => { 。。。 })
如上写法,我们就不必在代码的末尾声明Form.create()。(如:export default connect(mapStateToProps, mapDispatchToProps)(Form.create()(UpdateProdtype))
就不必有Form.create()了。)。
最后,关于mapStateToProps, mapDispatchToProps我也在另一篇博客中说明—React依赖注入说明(mapStateToProps/mapDispatchToProps)
阅读全文
0 0
- 解决antd Cannot read property 'validate' of undefined
- ExtJS错误解决 Cannot read property 'on' of undefined
- 解决jquery报错cannot read property 'length' of undefined
- 解决dataTable 报错:cannot read property "style" of undefined
- "TypeError: Cannot read property 'undefined' of undefined"
- Uncaught TypeError: Cannot read property 'call' of undefined jquery.validate.min.js:28
- Cannot read property 'autoCreated' of undefined
- TypeError: Cannot read property 'parentNode' of undefined
- Cannot read property 'nodeType' of undefined
- Cannot read property 'xxx' of undefined
- TypeError: Cannot read property 'left' of undefined
- Vue2-Cannot read property 'component' of undefined
- [Jquery]Cannot read property 'msie' of undefined
- Cannot read property ‘msie’ of undefined
- Cannot read property ‘msie’ of undefined
- Cannot read property 'rownumbers' of undefined
- TypeError: Cannot read property 'newLine' of undefined
- TypeError: Cannot read property 'password' of undefined
- [Android Studio系列(五)] Android Studio手动配置Gradle的方法
- NYOJ 756 重建二叉树
- 【mysql】insert的几种方式
- com.google.gson.JsonSyntaxException的解决方法
- android-clipChildren属性
- 解决antd Cannot read property 'validate' of undefined
- mysql 5.19 windows安装后无法启动服务
- Leetcode挑战题——2 Keys Keyboard
- STM32F103系列 PB4引脚问题
- CSRF攻击防御---验证HTTP Referer
- HDU 1538 A Puzzle for Pirates(经典好题,海盗分金问题)
- 第八篇 :微信公众平台开发实战Java版之如何网页授权获取用户基本信息
- 深度解析AbstractQueuedSynchronizer实现原理(上)
- PCDN服务接入实操手册