Angular2(RC-4):无法读取未定义的属性“pathsWithParams”

2024-01-01

在 angular2 RC-4 中使用子路由时出现此错误

无法读取未定义的属性“pathsWithParams”

我的路由文件包含

export const routes: RouterConfig = [
  { path: '', component: HomeComponent },
  { path: 'demo', component: DummyComponent },
  { path: 'user-profile', component: UserProfileComponent,
    children:[
      { path: '', component: ProfileOverview },
      { path: 'smart-points', component: ProfileSmartPoints }
    ]},
]

任何想法 ?

update

问题实际上是每当我使用routerLinkActive在 html 端


得到答案谢谢@micronyks

实际上问题是我们必须使用该属性[routerLinkActiveOptions]="{exact: true}"使用时routerLinkActive="active-link"在 html 中检查活动路由。

所以正确的语法是:

<a routerLinkActive="active" [routerLinkActiveOptions]="{exact:true}" [routerLink]='["./Dummy"]'>Dummy</a>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Angular2(RC-4):无法读取未定义的属性“pathsWithParams” 的相关文章

随机推荐