加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在Angular2 RC4中如何将组件添加到预编译数组?

发布时间:2020-12-17 08:19:40 所属栏目:安全 来源:网络整理
导读:我刚刚将我的Angular2项目更新为RC4,当我打开我的应用程序时,路由器现在正在控制台中发出此警告消息: router.umd.js:2466 'FrontpageComponent' not found in precompile array. To ensure all components referred to by the RouterConfig are compiled,
我刚刚将我的Angular2项目更新为RC4,当我打开我的应用程序时,路由器现在正在控制台中发出此警告消息:
router.umd.js:2466 'FrontpageComponent' not found in precompile array.  To ensure all components referred to by the RouterConfig are compiled,you must add 'FrontpageComponent' to the 'precompile' array of your application component. This will be required in a future release of the router.

我试图弄清楚我需要做什么来解决这个问题,但由于文档稀疏,我找不到答案。这是什么预编译数组,哪里可以找到它,或者如何添加它?

在较新的路由器版本中,这不应该是必要的。

< = RC.4 这只是@Component()或@Directive()装饰器的一个附加参数:

@Component({
  selector: '...',template: '...',directives: [FrontpageComponent],precompile: [FrontpageCmponent]
})

https://github.com/angular/angular/blob/6c5b653593eff19c5b9342b2cf0195aca49379cb/modules/%40angular/core/src/metadata/directives.ts#L968

/** * Defines the components that should be precompiled as well when * this component is defined. For each components listed here,* Angular will create a {@link ComponentFactory ComponentFactory} and store it in the * {@link ComponentFactoryResolver ComponentFactoryResolver}.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读