【问题标题】:Angular 2 component not rendering on deployed versionAngular 2 组件未在已部署版本上呈现
【发布时间】:2017-01-30 09:33:04
【问题描述】:

不知何故,组件不会在 heroku 上的已部署版本中呈现,但在本地它可以正常工作。没有错误,什么都没有 - 它只是没有被渲染。

所以我在顶部有一个导航栏的模板,如下所示: (请不要说我使用的是 Angular Meteor 2.0,所以由于一些特殊的角度编译器,导入这样的模板很好。它可以工作。)

import { Component } from "@angular/core";
import template from "./about-navigation.html";
@Component({
  selector: "about-navigation",
  template,
})
export class AboutNavigation {
}

它在 app.module.ts 声明中:

...
import { AboutNavigation } from "./templates/about-navigation/about-navigation";
@NgModule({
  ...
  declarations: [ AppComponent,
                  About,
                  AboutNavigation,
                ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { } 

那么这是我的实际组件:

@Component({
  selector: "about",
  template,
})
export class About {
  constructor(private router: Router) {
    });
  }
}

及其模板:

<about-navigation></about-navigation>
<div class="container about-content page-transition" [@elementState]="pageTransition" >
    <router-outlet></router-outlet>
</div>

这个选择器&lt;about-navigation&gt;&lt;/about-navigation&gt; 是在将它部署到 Heroku 之后呈现的,但没有内容。 其他一切都很好。控制台中没有一个错误或警告。我不知道它可能是什么......

【问题讨论】:

  • 我相信在生产中你已经启用了隐藏所有错误的ProdMode。你能把它关掉吗?另外,我不确定您是否可以将 @ 用于您的输入
  • @LeoCaseiro '[@elementState]' 是trigger 我相信
  • 没错,我可以看到它在这里工作bergben.github.io/ng2-scrollimate。我没有意识到这一点。谢谢@snolflake
  • 是的@LeoCaseiro @elementState 是一个动画触发器。我也尝试停用 enableProdMode,然后我收到消息“angular is in development mode...”所以它确实有效,但仍然没有一个错误或任何东西...
  • 嗨@Benedikt。没有警告很难。如果你的 heroku 运行你的 npm 安装,你也许可以检查每个依赖项。它可能是与本地版本不同的单个包,以及 npm 和节点版本。也许将所有 node_modules 从本地推送到 Heroku。

标签: meteor heroku angular typescript


【解决方案1】:

似乎问题出在 RC5(这是 Angular Meteor 当前支持的版本),如https://github.com/angular/angular/issues/10618 所示。 我认为这在新版本中应该不是问题。

另外,我必须添加

@Component({
  moduleId: module.id,

【讨论】:

    猜你喜欢
    • 2016-06-04
    • 1970-01-01
    • 2016-08-02
    • 2018-04-14
    • 2020-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多