PrimeNG日历模块Angular 9

4

我使用的是 angular 9 和 primeng 9。

我有一个模块:ItemModule

import { CalendarModule } from 'primeng/calendar';

@NgModule({
    imports: [
       CalendarModule
       .....
    ],
    .....
})

但是我遇到了错误:
ERROR in node_modules/primeng/components/calendar/calendar.d.ts:246:22 - error NG6002:  
Appears in the NgModule.imports of ItemModule, but could not be resolved to an NgModule class.

This likely means that the library (primeng/calendar) which declares CalendarModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. 
Check if a newer version of the library is available, and update if so. 
Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

246 export declare class CalendarModule {

我在文档中看到,这个版本的primeng应该与Angular 9 Ivy兼容。

你对此有什么想法吗?提前感谢。

2个回答

3
在tsconfig.json中添加:
"angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true,
    **"enableIvy": false**
}

它似乎不是最终解决方案。Primeng 9 应该与使用 Ivy 的 Angular 9 兼容。我不想仅因为这个库的原因禁用 Ivy。 - julew

1
primeng版本升级到9.x.x(例如-9.1.3)。
这将根据angular下面所述的方式使用ngcc预编译模块。

如果您依赖于许多Angular库,您可以通过在npm postinstall脚本中调用ngcc(Angular兼容性编译器)来加快构建速度,方法是通过small change to your package.json


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接