【问题标题】:Angular 'mdb-navbar-brand' is not a known element:Angular 'mdb-navbar-brand' 不是已知元素:
【发布时间】:2019-07-18 20:20:02
【问题描述】:

我在参与 Angular 项目时遇到了这个错误。我不明白我该怎么办。谁能帮帮我?

SCRIPT5022: Template parse errors:
'mdb-navbar-brand' is not a known element:
1. If 'mdb-navbar-brand' is an Angular component, then verify that it is part of this module.
2. If 'mdb-navbar-brand' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("

【问题讨论】:

标签: angular angular7


【解决方案1】:

您需要先导入模块才能在组件中使用它。因此,在您的应用程序组件中导入它,如下所示。

import { MDBBootstrapModule } from 'angular-bootstrap-md';

@NgModule({
    imports: [
        MDBBootstrapModule.forRoot()
    ]
});

如果您使用 angular cli,请将 scss 添加到您的 angular.json 配置文件中

"node_modules/angular-bootstrap-md/scss/bootstrap/bootstrap.scss",
"node_modules/angular-bootstrap-md/scss/mdb-free.scss",

现在它应该适用于所有风格

【讨论】:

    【解决方案2】:

    这表示您需要在模块中导入组件,否则 HTML 标记 mdb-navbar-brand 找不到或无法识别为任何内容。

    import { MdbNavBar} from './mdb-nav-bar.component';
    

    【讨论】:

      猜你喜欢
      • 2019-06-27
      • 2020-05-23
      • 2021-09-02
      • 2019-11-13
      • 2020-02-08
      • 2018-10-13
      • 2017-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多