我想在我的项目中使用角万向盘。我补充说,我看到了错误:
ReferenceError: window is not defined我没有在我的项目中使用window,但是它可能在30部分库中使用。如何解决这个问题?
我已经看到了模拟问题:Angular 9 Universal ReferenceError: window is not defined --它的答案没有帮助。
发布于 2022-09-16 13:38:01
使用isPlatformServer通过检查封装代码
export class ArtistShowComponent {
constructor(@Inject(PLATFORM_ID) private platformId: Object) {
this.isServerSide = isPlatformServer(platformId);
}
isServerSide: boolean;
doSomething() {
// If the issue is in typescript
if (this.isServerSide) {
...
}
}
}如果问题位于第三方角组件/HTML中:
<!-- Remove the component from the DOM -->
<ng-carousel *ngIf="!isServerSide"></div>https://stackoverflow.com/questions/73700243
复制相似问题