gpt4 book ai didi

templates - Uncaught Error : No template specified for component MyApp

转载 作者:行者123 更新时间:2023-12-03 22:48:11 31 4
gpt4 key购买 nike

我正在尝试将我的 ionic 2 Beta 2 代码更新为 ionic 2 RC0,并且在我的 app.component.ts 文件中收到 No template specified 错误。
app.component.ts 文件的相关部分如下所示:

@Component({
templateUrl: 'app.html',
})

export class MyApp {
rootPage: any = HomePage;
loggedIn:boolean = false;

@ViewChild(Nav) nav: Nav;

root: any;// = HomePage;


constructor() {
...
}
}
根据更新应用程序以发布 ionic 2 的候选 0 的更新说明,app.html 文件与 app.component.ts 文件位于同一目录中,路径为 app.html在运行 ionic 应用程序时,Firefox 和 Chrome 都提示没有为 app.component 指定模板。

最佳答案

我遇到了同样的问题,导致的是注释行。即使您没有在示例中包含注释行,我也建议您使用该答案(我认为您没有想到注释行会导致错误)。以下产生与您相同的错误:

@Component({
//template: `<ion-nav [root]="rootPage"></ion-nav>`
templateUrl: 'app.html'
})

我必须进行以下更改才能使编译正常工作(在使用 ionic-app-scripts @ 0.0.30 时,我感觉问题出现在 v0.0.23 和 v0.0.30 之间,但我没有调查):
@Component({
templateUrl: 'app.html'
//template: `<ion-nav [root]="rootPage"></ion-nav>`
})

关于templates - Uncaught Error : No template specified for component MyApp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39936693/

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