在typescript中使用antd的form表单

32次阅读

共计 553 个字符,预计需要花费 2 分钟才能阅读完成。

在 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)

正文完
 0