Angular通配路由

Angular通配符路由

在写route的时候,需要将静态路由写在通配符路由之前,因为路由是从上之下解析的静态路由可能会被识别成通配符路由,导致页面呈现的是通配路由的component。
参考:angular路由
在这里插入图片描述
举个例子:

const routes = [{
  path: '',
  component: MainComponent,
  children: [{
    path: '',
    pathMatch: 'full',
    redirectTo: 'test1'
  }, {
    path: 'test',
    children: [{
      path: '',
      component: TestComponent,
    }, {
      path: 'test-child', // 静态路由
      component: TestChildComponent
    }, {
      path: ':child-kind', //通配路由
      component: TestChildKindComponent
    }]
  }
    }]
}];

若静态路由写在通配路由下,则跳转到’test-child’的路径下时,不会编译TestChildComponent,而是会被识别成:child-kind,编译TestChildKindComponent。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值