首页 > 解决方案 > Angular 'mdb-navbar-brand' 不是已知元素:

问题描述

我在从事 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. ("

标签: angularangular7

解决方案


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

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

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

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

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

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


推荐阅读