【发布时间】:2020-03-13 04:39:36
【问题描述】:
我有这样的对象数组:
export const EXAMPLE_CONFIG: IExampleConfig = [
{
urlPath: '/test/test',
page: 'test',
fields: {
fullName: 'a',
mobilePhoneNumber: 'b',
emailAddress: 'c',
.......
}
},
{
... same as above
},
]
我创建了一个这样的界面:
export interface IExampleConfig {
path: string;
pageTitle: string;
fields: { [key: string]: string };
}
它给了我错误:Type '({ path: string; pageTitle: string; fields: { fullName: string; mobilePhoneNumber: string; emailAddress: string; emailIsOwn: string; mediasource: string; }; } | { path: string; pageTitle: string; fields: { ...; }; } | ... 7 more ... | { ...; })[]' 缺少类型“IExampleConfig”的以下属性:路径、页面标题、字段
【问题讨论】:
-
EXAMPLE_CONFIG: IExampleConfig->EXAMPLE_CONFIG: IExampleConfig[]指定an array
标签: angular typescript dependency-injection