让我说我的app.module.ts中有这个
@NgModule({
imports: [
BrowserModule,
HttpModule,
RouterModule.forRoot([
{path: 'home', component: HomeComponent},
{path: '', redirectTo: 'home', pathMatch: 'full'},
{path: '**', component: NotFoundComponent},
]),
UserModule
...
})
这导致我认为这个路由顺序:
{path:'User',component:UserComponent},{path:'home',component:HomeComponent},{path:'',redirectTo:'home',pathMatch:'full'},{path:'** ',组件:NotFoundComponent}
请注意,User现在先于其他用户 .
现在我将部件RouterModule.ForRoot导出到另一个名为AppRoutingModule的模块 .
@NgModule({
imports: [
BrowserModule,
HttpModule,
AppRoutingModule, // newly created routing module
UserModule
...
})
在我看来,这导致了这一点:
{path:'home',component:HomeComponent},{path:'',redirectTo:'home',pathMatch:'full'},{path:'**',component:NotFoundComponent},{path:'User ',组件:UserComponent}
请注意,用户现在已经完成了其他用户 .
所以我必须将AppRoutingModule放在UserModule下面 . 为什么这样实现?
1 回答
以下是官方文档中的两个链接,可帮助您了解如何进行导入,以及如何了解当前的订单路径:
App.Module.ts
App.Module.ts