如果瀏覽器關閉,我需要執行一個 Api,例如中斷,從用戶關閉瀏覽器,PC 崩潰,ext ext。此功能在我的組件中,我不會在任何地方調用此功能,我認為它應該會自動激活。 @HostListener('window:beforeunload', ['$event']) beforeunloadHandler(event) { this.postService.unsetPost(this.postId).subscribe(); }但不工作。
在 Angular 中關閉瀏覽器后執行 API
飲歌長嘯
2021-12-23 15:08:13