[英]How to intercept scroll event in Angular 6?
How to prevent scroll event? 如何防止滚动事件?
I was trying to add event.preventDefault()
into the HostListener but it's not working. 我试图将
event.preventDefault()
添加到HostListener中,但是它不起作用。 event.stopPropagation()
and event.stopImmediatePropagation()
are not working too. event.stopPropagation()
和event.stopImmediatePropagation()
也不起作用。
I need to implement some logic instead of scrolling. 我需要实现一些逻辑而不是滚动。
@HostListener('window:scroll', ['$event'])
onScroll(event) {
event.preventDefault();
console.log('Hello World');
}
尝试使用'wheel'
而不是'window:scroll'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.