【发布时间】:2021-10-16 19:25:03
【问题描述】:
我正在尝试按照此处的文档使用 Ant Design Pro Form:https://procomponents.ant.design/en-US/components/modal-form/
但是,在尝试重现他们的示例时,我不断收到语法错误。 导致问题的原因是这种特殊的语法:
<DrawerForm<{
name: string;
company: string;
}>
title="..."
...
>
我最初认为它是特定于 Ant Design Pro 的自定义语法,直到我意识到它可能是 Typescript JSX。但是我完全无法在反应文档(也不是打字稿文档)中找到这样的语法。
我知道DrawerForm<{name: string; company: string;}> 可能是一种模板类型,{name: string; company: string;} 是一种应该表示表单模型的数据结构,但没有什么清楚解释。
这可以省略吗?这里有什么意义(这个结构甚至与表单字段不匹配)。
否则,我在此页面 (https://procomponents.ant.design/en-US/components/form) 上的示例代码中遇到了困难:
// Set overall default values
<ProForm initialValues={obj} />
// Set the individual control's
<ProForm
onValuesChange={(changeValues) => console.log(changeValues)}
>
<ProFormText initialValue="prop"/>
</ProForm>.
// Interdependent component linkage
<ProForm
<ProForm.Item noStyle shouldUpdate>
{(form) => {
return (
<ProFormSelect
options={[
{
value: "chapter",
label: "Effective when stamped",
},
]}
width="md"
name="useMode"
label={`with${form.getFieldValue("name")}contract agreement effective mode`}
/>
);
}}
</ProForm.Item>.
</ProForm>;
// Using custom components
<ProForm
<ProForm.Item name="switch" label="Switch" valuePropName="checked">
<Switch />
</ProForm.Item
</ProForm
这似乎是不稳定的,标签是未封闭的。你能确认不只是我错过了什么吗?
【问题讨论】:
标签: reactjs typescript jsx antd ant-design-pro