我使用react jsonschema-form和@rjsf/antd (Ant Design)。
在Ant组件中,它们有一个名为size
的属性,顾名思义,它控制不同输入字段(Form.Item
)的大小。
https://ant.design/components/form/#Form
我希望在react jsonschema-form的Form
属性中包含Form
属性。我本来希望react jsonschema-form的Form
会将任何额外的道具传递给Ant Form
,但情况似乎并非如此。
我该如何包括size
感谢你的帮助!
https://codesandbox.io/s/brave-poitras-jdshu0?file=/src/App.js
发布于 2022-09-12 11:22:15
您应该使用_internalFormWrapper
支柱,作为RJSF的版本<5。
import { Form as AntdForm } from 'antd';
import { withTheme } from '@rjsf/core';
import { Theme as AntDTheme } from '@rjsf/antd';
interface MyComponentProps { size: 'small' | 'middle' | 'large' }
const MyComponent = ({ size, ...props }: MyComponentProps): JSX.Element => {
function MyAntdForm() {
return <AntdForm size={size} />;
}
const Form = withTheme<FormValues>(Theme);
return <Form {...props} _internalFormWrapper={MyAntdForm} >
}
https://stackoverflow.com/questions/72584990
复制相似问题