p-menuitem 不是已知元素 - primeng

问题描述

我是 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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...