Angular 需要先初始化一個 platform。當在伺服器上使用 bootstrapApplication,卻沒有提供 BootstrapContext 時,就會拋出這個錯誤。
使用伺服器端渲染時,bootstrapApplication 需要把 BootstrapContext 作為引數傳入。
如何除錯
要解決這個錯誤,請確保你的 main.server.ts 檔案有正確地把 BootstrapContext 傳給 bootstrapApplication 函式。
import {bootstrapApplication, BootstrapContext} from '@angular/platform-browser';
import {App} from './app/app';
import {config} from './app/app.config.server';
const bootstrap = (context: BootstrapContext) => bootstrapApplication(App, config, context);
export default bootstrap;