gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 16:53:15 24 4
gpt4 key购买 nike

我刚刚将我的 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}.

关于angular - 在 Angular2 RC4 中,如何将组件添加到预编译数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38144547/

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