Javascript 带参数的角度路由器
我用包含id和子路由的父路由创建了一个路由器。问题是,当我想使用选项卡在我的子路由下导航时,会出现一个错误: 错误:无法匹配任何路由。URL段:'tabs/user/1/overview'。 错误:无法匹配任何路由。URL段:'tabs/user/1/overview' 用户路由器:Javascript 带参数的角度路由器,javascript,angular,typescript,angular-ui-router,Javascript,Angular,Typescript,Angular Ui Router,我用包含id和子路由的父路由创建了一个路由器。问题是,当我想使用选项卡在我的子路由下导航时,会出现一个错误: 错误:无法匹配任何路由。URL段:'tabs/user/1/overview'。 错误:无法匹配任何路由。URL段:'tabs/user/1/overview' 用户路由器: export const routes: Routes = [ { path: 'user/:id', component: UserdetailComponent, resolve: { test:
export const routes: Routes = [
{
path: 'user/:id',
component: UserdetailComponent,
resolve: {
test: dataResolver,
},
children: [
{ path: '', redirectTo: 'overview', pathMatch: 'full' },
{ path: '', redirectTo: 'overview', pathMatch: 'full' },
{ path: 'overview', loadChildren: () =>
import('./overview-module/overview.module').then(
m => m.OverviewModule
)
},
{ path: 'contact', loadChildren: () =>
import('./contact-module/contact.module').then(
m => m.ContactModule
)
},
]}];
export const UserModule: ModuleWithProviders = RouterModule.forChild(
routes
);
路线概述:
@NgModule({
declarations: [OverviewComponent],
imports: [
CoreModule,
RouterModule.forChild([
{
path: '',
component: OverviewComponent,
}
]),
],
exports: [OverviewComponent]
})
导出类概览模块{}
和“我的选项卡”的一个按钮:
<ion-button
size="small"
fill="clear"
color="text"
[routerLink]="[userId, 'overview']"
我认为您需要将路由器链接更改为
[routerLink]="['/tabs/user', userId, 'overview']"
我们需要先指定父路径,然后才能添加子路径。让我知道它是否有效。您能提供完整的routetable代码吗?错误是它找不到路线。并不是说它找不到相应的组件/模块。在有问题的管线中,第一个管线段是“选项卡”。我在您提供的路由配置中找不到该段。是否在概览模块中创建了路由配置?感谢您的回复。我编辑了我的帖子。是的,我在概览模块中有一个路由配置,如果我在第一个参数上添加/它就可以工作:)