我是primeng的新手,遇到了这个困难。当我将 ap-menuitem
放入 ap-menubar
时,角度会给我以下错误:
'p-menuitem' is not a known element:
1. If 'p-menuitem' is an Angular component, then verify that it is part of this module.
2. If 'p-menuitem' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
现在我明白我需要在 app.module.ts 中添加模块,我做了:
app.module.ts 代码:
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import {MenubarModule} from 'primeng/menubar';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
MenubarModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
HTML 代码:
<p-menubar [model]="items">
<p-menuitem>Any code here</p-menuitem>
</p-menubar>
我还将它导入MenubarModule
到与 HTML 相同的 component.ts 中,导入行虽然在那里褪色。我在这里缺少什么吗?
版本:
"@angular/common": "~12.0.3"
"@angular/compiler": "~12.0.3"
"@angular/core": "~12.0.3"
"primeng": "12.0.0"
"primeicons": "4.1.0"