【发布时间】:2022-04-18 12:04:05
【问题描述】:
我在我的 AppComponent 类中写了@HostListener 来检测浏览器关闭或标签关闭。
我已经编写了这段代码,但它不起作用。请帮助我了解为什么我的代码不起作用
下面是我的代码。
export class AppComponent {
@HostListener('window:unload', [ '$event' ])
unloadHandler(event) {
alert('call unload');
}
@HostListener('window:beforeunload', [ '$event' ])
beforeUnloadHander(event) {
alert('call beforeunload');
}
}
【问题讨论】:
标签: javascript angular typescript angular6 angular5