我收到错误消息“错误:无法匹配任何路由。URL段:'admin-home / admin-fixtures' 错误:无法匹配任何路线。 URL段:“ admin-home / admin-fixtures”” 当我尝试转到包含标签的页面
我的主页也是一个标签页(最初是从ionic生成的),这就是我要遵循的示例。
这是我认为相关的代码。在我的页面之一Login.mhtl中,我单击一个按钮,将我链接到admin-home,该页面应该是包含3个标签的页面
this.router.navigateByUrl('admin-home');
这是我的admin-home.html的代码
<ion-header>
<ion-toolbar color="dark" class="ion-icon-toolbar">
<ion-buttons slot="start">
<ion-button (click)="goBack()"><ion-icon slot="icon-only"
name="arrow-back"></ion-icon></ion-button>
</ion-buttons>
<ion-title>Admin Home</ion-title>
<ion-buttons slot="end">
<ion-button (click)="logOut()">
<ion-icon slot="icon-only" name="log-out"></ion-icon>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content padding>
<ion-tabs>
<ion-tab-bar slot="top">
<ion-tab-button tab="admin-fixtures">
<ion-label>Fixtures</ion-label>
</ion-tab-button>
<ion-tab-button tab="admin-players">
<ion-label>Players</ion-label>
</ion-tab-button>
<ion-tab-button tab="admin-admins">
<ion-label>Admins</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
</ion-content>
这是admin-home.router.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AdminHomePage } from './admin-home.page';
const routes: Routes = [
{
path: 'admin-home',
component: AdminHomePage,
children: [
{ path: 'admin-fixtures', loadChildren: '../admin-fixtures/admin-fixtures.module#AdminFixturesPageModule'},
{ path: 'admin-players', loadChildren: '../admin-players/admin-players.module#AdminPlayersPageModule'},
{ path: 'admin-admins', loadChildren: '../admin-admins/admin-admins.module#AdminAdminsPageModule'},
]
},
{
path: '',
redirectTo: '/admin-home/admin-fixtures',
pathMatch: 'full'
}
];
@NgModule({
imports: [
RouterModule.forChild(routes)
],
exports: [RouterModule]
})
export class AdminHomePageRoutingModule {}
添加admin-fixture.module.ts代码
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { AdminFixturesPage } from './admin-fixtures.page';
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
RouterModule.forChild([{ path: '', component: AdminFixturesPage }])
],
declarations: [AdminFixturesPage]
})
export class AdminFixturesPageModule {}