Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'tabs/tab1/discover/a1'
Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'tabs/tab1/discover/a1'
谁能帮我解决这个问题?我觉得我的选项卡路由页面设置不正确,但每次我尝试修复它时,它都会崩溃。
我创建了一个离子 angular 标签应用程序。我在本地存储了数据,这些数据显示在“发现”页面上的卡片显示中。单击一张卡片后,我想转到该卡片的主页,但我得到的是下面显示的错误。
应用-routing.module.ts:
const routes: Routes = [
{ path: '', redirectTo: 'places', pathMatch: 'full' },
{ path: 'auth', loadChildren: () => import('./auth/auth.module').then(m => m.AuthPageModule) },
{
path: 'places',
loadChildren: () => import('./places/places.module').then(m => m.PlacesPageModule),
canLoad: [AuthGuard]
},
{
path: 'bookings',
loadChildren: () => import('./bookings/bookings.module').then(m => m.BookingsPageModule),
canLoad: [AuthGuard]
}
];
制表符-routing.module.ts:
const routes: Routes = [
{
path: '',
component: TabsPage,
children: [
{
path: 'tab1',
children: [
{
path: '',
loadChildren: () => import('../tab1/tab1.module').then(m => m.Tab1PageModule)
},
{
path: ':artistId',
loadChildren: () => import('../tab1/discover/artist-details/artist-details.module').then(m => m.ArtistDetailsPageModule)
},
{
path: ':venueId',
loadChildren: () => import('../tab1/discover/venue-details/venue-details.module').then(m => m.VenueDetailsPageModule)
}
]
},
Discover.page.html:
<ion-content class="ion-padding">
<ion-grid>
<ion-row>
<ion-col size="12" size-sm="8" offset-sm="2">
<ion-card
fill="clear"
[routerLink]="['/','tabs','tab1','discover',loadedArtist[0].id]"
>
<ion-card-header>
<ion-card-title>{{ loadedArtist[0].name }}</ion-card-title>
<ion-card-subtitle
>{{ loadedArtist[0].cost | currency }} / Night</ion-card-subtitle
>
</ion-card-header>
<ion-img [src]="loadedArtist[0].imageUrl"></ion-img>
<ion-card-content>
<p>Rating: {{ loadedArtist[0].rating | percent}}</p>
<p>Genre: {{ loadedArtist[0].genre }}</p>
<p>Equipment: {{ loadedArtist[0].equipment }}</p>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
<ion-row>
<ion-col size="12" size-sm="8" offset-sm="2">
<ion-card
*ngFor="let artist of loadedArtist.slice(1)"
fill="clear"
[routerLink]="['/','tabs','tab1','discover',artist.id]"
>
<ion-card-header>
<ion-card-title>{{ artist.name }}</ion-card-title>
<ion-card-subtitle
>{{ artist.cost | currency }} / Night</ion-card-subtitle
>
</ion-card-header>
<ion-img [src]="artist.imageUrl"></ion-img>
<ion-card-content>
<p>Rating: {{ artist.rating | percent}}</p>
<p>Genre: {{ artist.genre }}</p>
<p>Equipment: {{ artist.equipment }}</p>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
<ion-row></ion-row>
</ion-grid>
</ion-content>
需要正确构建路由路径。尝试更改:
{
path: ':artistId',
loadChildren: () => import('../tab1/discover/artist-details/artist-details.module').then(m => m.ArtistDetailsPageModule)
},
至
{
path: 'discover/:artistId',
loadChildren: () => import('../tab1/discover/artist-details/artist-details.module').then(m => m.ArtistDetailsPageModule)
},
谁能帮我解决这个问题?我觉得我的选项卡路由页面设置不正确,但每次我尝试修复它时,它都会崩溃。
我创建了一个离子 angular 标签应用程序。我在本地存储了数据,这些数据显示在“发现”页面上的卡片显示中。单击一张卡片后,我想转到该卡片的主页,但我得到的是下面显示的错误。
应用-routing.module.ts:
const routes: Routes = [
{ path: '', redirectTo: 'places', pathMatch: 'full' },
{ path: 'auth', loadChildren: () => import('./auth/auth.module').then(m => m.AuthPageModule) },
{
path: 'places',
loadChildren: () => import('./places/places.module').then(m => m.PlacesPageModule),
canLoad: [AuthGuard]
},
{
path: 'bookings',
loadChildren: () => import('./bookings/bookings.module').then(m => m.BookingsPageModule),
canLoad: [AuthGuard]
}
];
制表符-routing.module.ts:
const routes: Routes = [
{
path: '',
component: TabsPage,
children: [
{
path: 'tab1',
children: [
{
path: '',
loadChildren: () => import('../tab1/tab1.module').then(m => m.Tab1PageModule)
},
{
path: ':artistId',
loadChildren: () => import('../tab1/discover/artist-details/artist-details.module').then(m => m.ArtistDetailsPageModule)
},
{
path: ':venueId',
loadChildren: () => import('../tab1/discover/venue-details/venue-details.module').then(m => m.VenueDetailsPageModule)
}
]
},
Discover.page.html:
<ion-content class="ion-padding">
<ion-grid>
<ion-row>
<ion-col size="12" size-sm="8" offset-sm="2">
<ion-card
fill="clear"
[routerLink]="['/','tabs','tab1','discover',loadedArtist[0].id]"
>
<ion-card-header>
<ion-card-title>{{ loadedArtist[0].name }}</ion-card-title>
<ion-card-subtitle
>{{ loadedArtist[0].cost | currency }} / Night</ion-card-subtitle
>
</ion-card-header>
<ion-img [src]="loadedArtist[0].imageUrl"></ion-img>
<ion-card-content>
<p>Rating: {{ loadedArtist[0].rating | percent}}</p>
<p>Genre: {{ loadedArtist[0].genre }}</p>
<p>Equipment: {{ loadedArtist[0].equipment }}</p>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
<ion-row>
<ion-col size="12" size-sm="8" offset-sm="2">
<ion-card
*ngFor="let artist of loadedArtist.slice(1)"
fill="clear"
[routerLink]="['/','tabs','tab1','discover',artist.id]"
>
<ion-card-header>
<ion-card-title>{{ artist.name }}</ion-card-title>
<ion-card-subtitle
>{{ artist.cost | currency }} / Night</ion-card-subtitle
>
</ion-card-header>
<ion-img [src]="artist.imageUrl"></ion-img>
<ion-card-content>
<p>Rating: {{ artist.rating | percent}}</p>
<p>Genre: {{ artist.genre }}</p>
<p>Equipment: {{ artist.equipment }}</p>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
<ion-row></ion-row>
</ion-grid>
</ion-content>
需要正确构建路由路径。尝试更改:
{
path: ':artistId',
loadChildren: () => import('../tab1/discover/artist-details/artist-details.module').then(m => m.ArtistDetailsPageModule)
},
至
{
path: 'discover/:artistId',
loadChildren: () => import('../tab1/discover/artist-details/artist-details.module').then(m => m.ArtistDetailsPageModule)
},