【发布时间】:2021-07-26 11:30:32
【问题描述】:
我有在关闭角度应用程序选项卡或整个浏览器时调用注销 api 的场景。我尝试了该方法
@HostListener('window:beforeunload', ['$event'])
doSomething($event: any) {
this.logout();
}
window.onbeforeunload = function (event) {
};
我尝试了这些方法,但似乎不起作用。
【问题讨论】:
-
``` @HostListener('window:beforeunload', ['$event']) doSomething($event: any) { this.logout(); }``` 上面的方法不行。