Angular 角度6:页脚(共享)组件中的mat工具栏和mat工具栏行显示不正确(但没有任何错误)?
我在写这篇文章的时候读过所有类似的问题,但是在列表中找不到解决方案 我搜索了以下链接,但找不到解决方案: Mat控件在组件上运行良好,但页脚组件除外。 我正在尝试在共享页脚组件中使用Mat工具栏和Mat工具栏行。我不知道为什么工具栏显示不正确。 起初,我得到了这个例外 未捕获错误:模板分析错误: “mat工具栏行”不是已知元素: 1.如果“mat toolbar row”是一个角度组件,则验证它是否是此模块的一部分。 2.如果“mat toolbar row”是Web组件,则将“CUSTOM_ELEMENTS_SCHEMA”添加到此组件的“@NgModule.schemas”以抑制此消息。(” 然后我在下面的页脚中添加了自定义元素和模式,异常消失了Angular 角度6:页脚(共享)组件中的mat工具栏和mat工具栏行显示不正确(但没有任何错误)?,angular,angular6,angular-material2,Angular,Angular6,Angular Material2,我在写这篇文章的时候读过所有类似的问题,但是在列表中找不到解决方案 我搜索了以下链接,但找不到解决方案: Mat控件在组件上运行良好,但页脚组件除外。 我正在尝试在共享页脚组件中使用Mat工具栏和Mat工具栏行。我不知道为什么工具栏显示不正确。 起初,我得到了这个例外 未捕获错误:模板分析错误: “mat工具栏行”不是已知元素: 1.如果“mat toolbar row”是一个角度组件,则验证它是否是此模块的一部分。 2.如果“mat toolbar row”是Web组件,则将“CUS
import { Component, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@Component({
selector: 'app-footer',
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.scss']
})
export class Footer
{
getYear()
{
return new Date().getUTCFullYear();
}
}
@NgModule({
exports: [Footer],
declarations: [Footer],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class FooterModule { }
现在我在浏览器控制台中没有任何异常,我的应用程序正在工作,但现在没有显示mat工具栏和mat工具栏行元素的颜色和图标效果。应用程序只显示原始数据,而不是准确显示
我的页脚组件是:
<footer class="app-footer">
<div class="app-footer-link">
<p>
<span>VAA</span> © {{getYear()}}
<a href="https://www.VAA.com" target="_blank">www.VAA.com</a>
</p>
</div>
<mat-toolbar color="primary">
<mat-toolbar-row>
<span>Custom Toolbar</span>
</mat-toolbar-row>
<mat-toolbar-row>
<span>Second Line</span>
<span class="example-spacer"></span>
<mat-icon class="example-icon">verified_user</mat-icon>
</mat-toolbar-row>
<mat-toolbar-row>
<span>Third Line</span>
<span class="example-spacer"></span>
<mat-icon class="example-icon">favorite</mat-icon>
<mat-icon class="example-icon">delete</mat-icon>
</mat-toolbar-row>
</mat-toolbar>
</footer>
我想按原样显示此示例:
请查看此URL:这是因为您必须导入自定义模块中的组件正在使用的必要模块!请参阅以下内容:
@NgModule({
进口:[
公共模块,
Maticon模块,
Mattoolbar模块,
// ...
],
声明:[
页脚,
// ...
]
})
导出类页脚模块{}
谢谢你,Edric。有一件事mat图标不起作用。
<mat-sidenav-content>
<div fxLayout="column" fxFill>
<div id="mainContent" fxFlex>
<router-outlet></router-outlet>
</div>
<app-footer></app-footer>
</div>
</mat-sidenav-content>
</mat-sidenav-container>
@mixin footer-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
$background: map-get($theme, background);
$foreground: map-get($theme, foreground);
app-footer {
.app-footer {
background: mat-color($primary);
color: mat-color($primary, default-contrast);
}
.app-footer-link a {
color: mat-color($primary, default-contrast);
}
}
}