我对 dojo/on 和处理 mouseenter 和 mouseleave 有疑问。它对我不起作用...我准备了示例代码:
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8/dojo/dojo.js" data-dojo-config="async: 1"></script>
</head>
<body>
<div id="test">TEST</div>
</body>
</html>
<script type="text/javascript">
require(["dojo/dom", "dojo/on","dojo/domReady!"], function(dom, on) {
on(dom.byId('test'), 'mouseenter', function() { alert('12'); });
});
</script>
如果您尝试在 Chrome 中打开它,它不起作用,但如果您在 Opera、FF 或 IE 中打开它,它就可以正常工作。我做错了什么或者还有其他方法可以在 mouseenter 和 mouseleave 上使用吗? over and out 在 Chrome 中有效,但想继续使用 enter and leave。
最佳答案
使用Extension Events的 dojo/mouse
模块:
require(["dojo/dom", "dojo/on", "dojo/mouse"], function(dom, on, mouse) {
on(dom.byId('test'), mouse.enter, function() { alert('12'); });
});
在这个 jsFiddle 中查看它是如何工作的:http://jsfiddle.net/phusick/gUNuC/
关于javascript - dojo/on with mouseenter, mouseleave 在 Google Chrome 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12857569/