Tom*_*Tom 4 abstract-class types class typescript angular
我如何在typeof BaseListComponent下面指定?
下面的代码引发以下错误:
类型'
({ title: string; component: typeof QuestionsListComponent; } | { title: string; component: ...'不能分配给类型'{ title: string; component: typeof BaseListComponent; }[]'.
摘抄:
abstract class BaseListComponent {
protected title
}
class WeatherListComponent extends BaseListComponent {}
class QuestionsListComponent extends BaseListComponent {}
let containerItems: Array<{title: string, component: typeof BaseListComponent}>;
containerItems = [
{title:'TypeScript', component: QuestionsListComponent},
{title:'Angular2', component: QuestionsListComponent},
{title:'Weather', component: WeatherListComponent}
]
Run Code Online (Sandbox Code Playgroud)
PS这是一个角度应用程序的简化摘录,所以这种疯狂背后有逻辑.
| 归档时间: |
|
| 查看次数: |
1661 次 |
| 最近记录: |