gpt4 book ai didi

Angular2 TypeScript 指令错误 TS2345

转载 作者:太空狗 更新时间:2023-10-29 16:56:13 27 4
gpt4 key购买 nike

当我使用 tsc 编译我的应用程序时,我收到此错误 TS2345:

error TS2345: 
Argument of type '{ selector: string; template: string; directives: (typeof Title | any[])[]; providers: typeof Goo...' is not assignable to parameter of type 'ComponentMetadataType'.

这是我的代码:

import { Component, Input } from "@angular/core";
import { Title } from "./components/title";
import { Timeline } from "./components/timeline";

@Component({
selector: "edu",
template: `
<div id="Edu" class="Edu content section scrollspy">
<title [icon]="titleIcon" [title]="titleTitle"></title>
<timeline [data]="edu"></timeline>
</div>
`,
directives: [Title, Timeline]
})

export class Edu {
private titleIcon = "graduation-cap";
private titleTitle = "Education";
@Input("data") edu: Array<Object>;
}

我没有发现我的代码有任何问题,而且它曾经可以正常工作。谁能看出这有什么问题?

注意:我使用的是 Angular2-rc6 和 TypeScript 1.8.10,希望这些信息对您有所帮助

最佳答案

directives 已弃用并删除。TimeTimeline 现在应该放在你的 @NgModule 声明中:

@NgModule({
declarations: [Time, Timeline, ...],
...
})

关于Angular2 TypeScript 指令错误 TS2345,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39300476/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com