问题描述
愚蠢的问题,但我没有点击它。我有导航栏和后来的侧栏的主要布局。我还想渲染3个组件:产品,购物车,订单。
我在app.routing.modules.ts中创建了子路由,如下所示:
const routes: Routes = [
{
path: '',component: MainlayoutComponent,pathMatch: 'full',children: [
{ path: 'product',component: ProductsComponent },{ path: 'cart',component: CartComponent },{ path: 'order',component: OrderComponent },],},];
@NgModule({
imports: [RouterModule.forRoot(routes)],exports: [RouterModule],})
export class AppRoutingModule {}
从成角度开始已经很长时间了,所以我想我缺少了一些东西,但是无法完全点击。子组件设置错误?
Git网址:https://github.com/TyroniUA/ang
解决方法
当您将pathMatch = 'full'
推向pathMatch = 'prefix'
时有效
说明:
“完整”会导致网址匹配中其余的不匹配段是前缀路径时出现路由点击
“前缀”告诉路由器,当其余URL以重定向路由的前缀路径开头时,匹配路由重定向。