加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 5 EmptyError:在创建子路由时没有顺序元素

发布时间:2020-12-17 06:55:03 所属栏目:安全 来源:网络整理
导读:当我在路由中使用子项时,我无法从登录页面导航到仪表板页面,如下所示: const appRoutes: Routes = [{ path: '',redirectTo: 'login',pathMatch: 'full' },{ path: 'login',component: LoginComponent,{ path: 'dashboard',pathMatch: 'full',/* canActivate
当我在路由中使用子项时,我无法从登录页面导航到仪表板页面,如下所示:

const appRoutes: Routes = [
{ path: '',redirectTo: 'login',pathMatch: 'full' },{ path: 'login',component: LoginComponent,{
  path: 'dashboard',pathMatch: 'full',/* canActivate: [AuthGuard],*/ component: DashboardComponent,children: [
    {
      path: 'online-submission/:moduleName',component: OnlineSubmissionComponent,*/data:{
          breadcrumb: "online-submission"
      },children: [
        { path: 'batch-upload-members',component: BatchUploadMembersComponent,*/data:{
            breadcrumb: "batch-upload-members"
        } },{ path: 'select-members',component: SelectMembersComponent,*/data:{
            breadcrumb: "select-members"
        } 
       }
      ] 
    }
  ] 
},{ path: '**',component: PageNotFoundComponent }

].

但是,当我从路由中删除子属性并使其兄弟姐妹路由工作正常.制作儿童路线时有什么问题?我正在使用cli 1.6.0-rc.1

到目前为止我尝试了什么?

>评论AuthGuard没有用,所以问题不在于那部分
>我已经证实,只有当我将它们作为儿童路线(我需要制作面包屑)时才会出现这个问题.如果所有路由都是兄弟,则路由正常
>在RouterModule.forRoot中使用{enableTracing:true},我在其中找到NavigationStart(id:4,url:’/ dashboard’),这对于DashboardComponent来说似乎是正确的url
>在SO上搜索类似的标题问题,但没有人解决同一问题:

Angular 2.0.1 Router EmptyError: no elements in sequence

Angular2 routing issues – Zone aware error No elements in sequence

Angular 2.0.1 Router EmptyError: no elements in sequence

解决方法

此错误是由Angular的路由器的最新版本引起的.
请删除还原角度版本或添加pathMatch:’full’到您的路线.

export const userRoutes = [
    { path: 'profile',component: ProfileComponent,pathMatch: 'full' }
];


export const appRoutes = [
    { path: '',redirectTo: '/events',{ path: 'user',loadChildren: './user/user.module#UserModule' }
];

你可以找到问题here

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读