Angular Universal显示白色屏幕

时间:2020-09-02 09:46:04

标签: angular angular-ui-router server-side-rendering angular-universal

我已经将Angular Universal安装到了现有的Angular App中。它正在构建而没有任何错误,但是当我尝试检查localhost:4000时,它只是显示空白屏幕。不知道是什么问题。我猜我的路由有问题吗?我正在附上我的app-routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { PageNotFoundComponent } from './page-not-found/page-not-found.component';

import { AuthGuard } from './guard/auth.guard';
import { ContactUsComponent } from './contact-us/contact-us.component';
import { AboutUsComponent } from './about-us/about-us.component';
import { FeaturesComponent } from './features/features.component';
import { AllTemplatesComponent } from './all-templates/all-templates.component';

const routes: Routes = [
  {
    path: '',
    redirectTo: 'home',
    pathMatch: 'full',
  },
  {
    path: 'auth',
    loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule)
  },
  {
    path: 'home',
    component: HomeComponent,
  },
  {
    path: 'account',
    loadChildren: () => import('./header/header.module').then(m => m.HeaderModule),
    canActivate: [AuthGuard],
  },
  {
    path: 'demo',
    loadChildren: () => import('./cards/cards.module').then(m => m.CardsModule)
  },
  {
    path: '',
    loadChildren: () => import('./dynamic-card/dynamic-card.module').then(m => m.DynamicCardModule)
  },
  {
    path: 'home/contact-us',
    component: ContactUsComponent
  },
  {
    path: 'home/about-us',
    component: AboutUsComponent
  },
  {
    path: 'home/features',
    component: FeaturesComponent
  },
  {
    path: 'home/templates',
    component: AllTemplatesComponent
  },
  // {
  //   path: '**',
  //   pathMatch: 'full',
  //   component: PageNotFoundComponent,
  // },
];

@NgModule({
  imports: [RouterModule.forRoot(routes), RouterModule.forRoot(routes, {
    scrollPositionRestoration: 'enabled',
    initialNavigation: 'enabled'
})],
  exports: [RouterModule],
})
export class AppRoutingModule { }

请帮助我解决此问题。

0 个答案:

没有答案
相关问题