【发布时间】:2018-01-20 15:52:36
【问题描述】:
我很高兴在 https://material.angular.io/components/tabs/api#MatTab 找到有关材料选项卡的内容,并很高兴在我的项目中使用它。
我按照建议添加了导入,但它不起作用。我找到了:can not find module "@angular/material" 并导入了这些东西,并在我的 maintab 组件上进行了导入。
但是 mat-tab 链接仍然不起作用。所以这是我的 maintab.component.ts
import { Component, OnInit } from '@angular/core';
import {MatTabsModule} from '@angular/material';
@Component({
selector: 'app-maintab',
templateUrl: './maintab.component.html',
styleUrls: ['./maintab.component.css']
})
export class MaintabComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
这是我的 maintab.component.html
<mat-tab-group>
<mat-tab label="One">
<h1>Some tab content</h1>
<p>...</p>
</mat-tab>
<mat-tab label="Two">
<h1>Some more tab content</h1>
<p>...</p>
</mat-tab>
</mat-tab-group>
我仍然收到这些类型的错误:
Error: Template parse errors:
'mat-tab' is not a known element:
1. If 'mat-tab' is an Angular component, then verify that it is part of this module.
2. If 'mat-tab' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<mat-tab-group>
[ERROR ->]<mat-tab label="One">
<h1>Some tab content</h1>
<p>...</p>
"): ng:///AppModule/MaintabComponent.html@1:2
'mat-tab' is not a known element:
1. If 'mat-tab' is an Angular component, then verify that it is part of this module.
2. If 'mat-tab' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<p>...</p>
</mat-tab>
我只是不知道下一步该做什么。
【问题讨论】:
-
想通了所有这些。写了heavyweightsoftware.com/blog/how-to-use-tabs-with-angular-5 并提供了一个解决未来人们问题的演练。
标签: javascript angular typescript angular-material