0

在我的应用程序中,URLn 中可以有 n 个参数,然后它也可以有一个可选的跟随模式。例如,URL 可以是

http://example.com/{param1}

http://example.com/{param1}/constant/{id}

http://example.com/{param1}/{param2}/constant/{id}

http://example.com/{param1}/{param2}

http://example.com/{param1}/{param2}/{param3}

http://example.com/{param1}/{param2}/{param3}/constant/{id}

ETC

如何为这些类型的 URL 构建路由模块?

4

1 回答 1

0

你的意思是这样吗?

RouterModule.forChild([
  { path: 'api/whatever/:id1/', component: ComponentName}
  { path: 'api/whatever/:id1/dosomething/:id2', component: ComponentName}
  { path: 'api/whatever/:id1/:id2', component: ComponentName}
  { path: 'api/whatever/:id1/:id2/dosomething/:id3/dosomemore', component: ComponentName}
])
于 2017-04-06T12:23:39.860 回答