在Angular 7中,可以使用Angular Material库中的标签页组件(mat-tab-group和mat-tab)来创建组件标签页。下面是一个包含代码示例的解决方法:
npm install --save @angular/material @angular/cdk @angular/animations
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatTabsModule } from '@angular/material/tabs';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
MatTabsModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
Content of Tab 1
Content of Tab 2
Content of Tab 3
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
// Component logic goes here
}
ng serve
以上代码示例中创建了一个具有3个标签页的组件标签页。每个标签页都包含了一些示例内容。你可以根据自己的需求自定义标签页的内容和样式。