Why white screen stuck after splash screen in Ionic 4?

前端 未结 8 1695
盖世英雄少女心
盖世英雄少女心 2020-12-19 02:11

I run ionic cordova run android for my Ionic Cordova project. At this time, I have my mobile connected to PC via USB. So when I run that command, it installs th

8条回答
  •  醉梦人生
    2020-12-19 02:42

    I also faced this problem, but in my case, the problem is with default routing.

    When App initializes it tries to open on default route that is Empty route, which further we redirect to the actual working route, In my case Empty route was redirected to "/dashboard".

    Example code

    const routes: Routes = [
      {
        path: '',
        redirectTo: 'dashboard',
        pathMatch: 'full'
      },
      {
        path: 'dashboard',
        canActivate: [AuthGuard],
        loadChildren: './home/home.module#HomePageModule'
      },
      { 
        path: 'login',
        loadChildren: './public/login/login.module#LoginPageModule' 
      }
    ]
    

    In the above code, my Empty route is redirecting to dashboard where [AuthGuard] is active, and it stuck in circulation, So I decided it redirect to the route where [AuthGuard] is not active, That is "/login" in my case. Updated code by redirecting to login where [Authgaurd] is not active.

     const routes: Routes = [
          {
            path: '',
            redirectTo: 'login',
            pathMatch: 'full'
          },
          {
            path: 'dashboard',
            canActivate: [AuthGuard],
            loadChildren: './home/home.module#HomePageModule'
          },
          { 
            path: 'login',
            loadChildren: './public/login/login.module#LoginPageModule' 
          }
     ]
    

    After building the project for Andriod, The app runs successfully.

    Justed posted the answer if anyone has this issue same like me on the same problem.

提交回复
热议问题