Gio*_*olo 4 html javascript components typescript
嗨,我正在使用 JS 和 TS 编写代码。我做了这个界面:
> interface IPLTableProps {
> Conf: [{ key: string, val: any }],
> Values?: [string],
> children?: ReactNode // TODO prendere children da React }
Run Code Online (Sandbox Code Playgroud)
我定义了这个接口来创建一个通用组件。当我尝试在另一个文件中使用此组件时,我显然不得不将 is 称为通用组件。但是这里出现了错误。称为 PLTable 的通用组件
<PLTable Conf={CONF}/>
Run Code Online (Sandbox Code Playgroud)
CONF 是一个数组,当我尝试运行时出现此错误。
TS2741:类型“{标签:字符串;”中缺少属性“0”。}[]' 但需要在类型 '[{ key: string; 价值:任何;}]'。
有人能帮我吗?
[type]定义一个具有单个元素的元组。您可能想要一个使用type[]或定义的数组Array<type>
interface IPLTableProps {
Conf: Array<{ key: string, val: any }>,
Values?: string[],
children?: ReactNode
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6372 次 |
| 最近记录: |