是使用 angular universal 來做 SSR?
@Kevin 對
配合這篇作法回應404
在ssr時,瀏覽器的developer tools → network 可以發現
<router-outlet></router-outlet>
沒有產生component相關的tag,e.g. <app-page></app-page>
我同事發現是window的關係
修改 app.server.module.ts後,就可以了
import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { createWindow } from 'domino';
import { AppModule } from './app.module';
import { AppComponent } from './app.component';
const window = createWindow() as any;
(global as any).window = window;
(global as any).document = window.document;
(global as any).Event = window.Event;
(global as any).KeyboardEvent = window.KeyboardEvent;
@NgModule({
imports: [AppModule, ServerModule],
bootstrap: [AppComponent],
})
export class AppServerModule {}
2個讚