在 angular 5 中进行构建时,“mat-select”不是已知元素

Shu*_*ham 5 production-environment angular-material angular5

我在我的 Angular 5 项目中使用延迟加载,我有一个共享模块,其中导入了所有材料组件,我在其他模块中使用此共享模块作为材料模块。

所有组件在开发模式下都可以正常工作,但是当我为生产进行构建时,它显示的错误'mat-select'不是已知元素,而没有显示任何行号。

我已经在使用角材料的组件和我的app.component.ts文件中导入了共享模块。我到处搜索,但没有运气。

小智 14

对于较新版本的 Angular(我使用的是 Angular 11):

import {MatSelectModule} from '@angular/material/select';
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅MatSelectModule API 。


小智 9

在您各自的模块中添加以下内容。

import { MatSelectModule } from '@angular/material';
Run Code Online (Sandbox Code Playgroud)

MatSelectModule进口。