在TypeScript中使用antd的form表单
如果你想在TypeScript中使用antd的from表单,在使用Form.create()方法时编辑器会报各种各样的错误,这是因为你没有规定form表单的interface。
如何使用?
代码如下
import React, { PureComponent } from 'react'
import { Form } from 'antd'
import { FormComponentProps } from 'antd/lib/form/Form' //获取form表单的interface
interface IProps { //定义所需的相应接口
onSave : any,
onEdit : any,
handlevisible : any
}
class FromModal extends PureComponent<IProps & FormComponentProps> {
constructor(props: IProps & FormComponentProps) {
super(props);
}
render () {
return (
<Form layout="vertical"></Form>
)
}
}
export default Form.create<IProps & FormComponentProps>()(FromModal)
发表回复