我在YAML中使用codeMirror编辑器。 我有以下代码。
@Output('appOnDebounce')
public debounceEvent: EventEmitter<any>;
event.relatedTarget在FireFox中不起作用。它可以在Chrome中正常运行。 关于如何解决这个问题有什么想法吗?
答案 0 :(得分:0)
您可以使用event.originalEvent
从jQuerys事件访问本机DOM,也许您可以在其中找到relatedTarget?同样根据MDN,event.relatedTarget
仅适用于某些事件。从MDN 2018-12-07复制:
The MouseEvent.relatedTarget read-only property is the secondary target for the mouse event, if there is one.
Event name target relatedTarget
focusin The EventTarget receiving focus The EventTarget losing focus
focusout The EventTarget losing focus The EventTarget receiving focus
mouseenter The EventTarget the pointing device entered to The EventTarget the pointing device exited from
mouseleave The EventTarget the pointing device exited from The EventTarget the pointing device entered to
mouseout The EventTarget the pointing device exited from The EventTarget the pointing device entered to
mouseover The EventTarget the pointing device entered to The EventTarget the pointing device exited from
dragenter The EventTarget the pointing device entered to The EventTarget the pointing device exited from
dragexit The EventTarget the pointing device exited from The EventTarget the pointing device entered to
For events with no secondary target, relatedTarget returns null.
其中没有blur
,但是我很确定blur
只是focusout
的别名。
或者,直接挂钩到普通javascript,jQuery被高估了:
editor[0].addEventListener( 'blur', function( event ){
// whatevs
}
(editor[0]
从返回的jQuery对象访问本机DOM元素)
否则,重构吗?
答案 1 :(得分:0)
CodeMirror onBlur事件处理程序将'event'作为第二个参数。 editor.on('blur',function(instance,event){});