问题描述
我是 Primeng 的新手并且遇到了这个困难。当我将 p-menuitem
放入 p-menubar
时,angular 会出现以下错误:
'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"
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)