停止事件传播在2角 [英] Stop event propagation in Angular 2
本文介绍了停止事件传播在2角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是阻止鼠标事件传播在2角最简单的方法?
我应该通过特殊的$事件对象,然后调用stopPropagation()或本人有一些其他的方式。例如,在流星我可以简单地从事件处理程序返回false。
What is the easiest way to stop mouse events propagation in Angular 2? Should I pass special $event object and call stopPropagation() myself or there is some other way. For example in Meteor I can simply return false from event handler.
推荐答案
最简单的是调用的事件处理程序停止传播。 $事件
工作在角2相同,并包含正在进行的事件(用它点击鼠标,鼠标事件等):
The simplest is to call stop propagation on an event handler. $event
works the same in Angular 2, and contains the ongoing event (by it a mouse click, mouse event, etc.):
(click)="onEvent($event)"
在事件处理程序,我们可以在那里停止传播:
on the event handler, we can there stop the propagation:
onEvent(event) {
event.stopPropagation();
}
这篇关于停止事件传播在2角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文