我刚刚将我的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.
我试图弄清楚我需要做什么来解决这个问题,但由于文档稀疏,我找不到答案。这是什么预编译数组,哪里可以找到它,或者如何添加它?
在较新的路由器版本中,这不应该是必要的。
原文链接:https://www.f2er.com/angularjs/144858.html< = RC.4 这只是@Component()或@Directive()装饰器的一个附加参数:
@Component({ selector: '...',template: '...',directives: [FrontpageComponent],precompile: [FrontpageCmponent] })
/** * 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}.