在TypeScript中使用antd的form表单
问题:在组件中无法获取props
结论:因为form.create是个高阶组件
import React from 'react'
import { Form} from 'antd'
import { FormComponentProps } from 'antd/es/form';
interface Props {
example: string
}
class Example extends React.Component<Props & FormComponentProps> {
render(){
...
}
}
export default Form.create<Props & FormComponentProps>()(Example)
本文探讨了在TypeScript中使用antd的Form组件时遇到的问题:无法在组件中获取props。通过分析发现,这是由于Form.create是一个高阶组件导致的。文章提供了具体的代码示例,展示了如何正确地定义组件属性并使用Form.create进行组件包装。
1466

被折叠的 条评论
为什么被折叠?



