首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >角度2中空的子路由

角度2中空的子路由
EN

Stack Overflow用户
提问于 2017-03-13 21:29:25
回答 1查看 1K关注 0票数 0

我已经在我的Angular 2应用程序中创建了一些子路线。

代码语言:javascript
运行
复制
   export const AFTER_LOGIN_ROUTES:Routes=[
  {path:'',component:LatestPositionComponent},
  {path:'add',component:AddNewFriendComponent},
  {path:'history',component:HistoryComponent}
  ];

当我访问http://localhost:4200/app/addhttp://localhost:4200/app/history时,一切正常。

但是对于http://localhost:4200/app,我得到了一个错误:

代码语言:javascript
运行
复制
EXCEPTION: Uncaught (in promise): Error: Error in :0:0 caused by: Cannot read property 'firstChild' of null
Error: Error in :0:0 caused by: Cannot read property 'firstChild' of null
    at ViewWrappedError.ZoneAwareError

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-13 21:33:23

如果您有一个没有子路由的空路径(''),请使用pathMatch: 'full'

代码语言:javascript
运行
复制
{path:'',component:LatestPositionComponent, pathMatch: 'full'},
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42764872

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档