📅  最后修改于: 2022-03-11 14:56:26.084000             🧑  作者: Mango
component.ts
import { Component, Inject } from '@angular/core';
import { PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
@Component({
selector: 'mySpecial',
templateUrl: './mySpecial.component.html'
})
export class MySpecialComponent {
isBrowser: boolean;
constructor( @Inject(PLATFORM_ID) platformId: Object) {
this.isBrowser = isPlatformBrowser(platformId);
}
}
component.html
Hello World
Steak
Pizza
Tacos