【问题标题】:dojo/on with mouseenter, mouseleave not working in Google Chromedojo/on with mouseenter,mouseleave 在 Google Chrome 中不起作用
【发布时间】:2012-10-12 10:58:25
【问题描述】:

我在使用 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 上使用?在 Chrome 中反复工作,但希望继续使用 enter 和 leave。

【问题讨论】:

    标签: javascript html google-chrome dojo dom-events


    【解决方案1】:

    使用Extension Eventsdojo/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/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-05
      • 2016-05-11
      • 1970-01-01
      • 2012-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多