jquery - Angular mouseenter 在 Chrome 中不起作用

标签 jquery angularjs google-chrome mouseenter

我正在用 Angular 编写我的第一个应用程序,并且遇到了 mouseenter 事件的问题。它在 Chrome 中根本不起作用。首先,我以为我的代码中有错误,但我在 Firefox 中检查了它,一切正常。我决定使用 jsfiddle 中的 mouseenter 测试一些代码,它看起来是一样的 - 在 Firefox 上可以,在 chrome 上不行 - 在 li 上的 mouseenter 之后,没有任何反应。

测试代码:

<!DOCTYPE html>
<html ng-app="my-app">
    <head>
        <meta charset="utf-8" />         
              <style>
            /* Put your css in here */
            button {
                position: relative;
                float:right;
                top:-40px;
                right:0;
            }
            li {
                background: #eee;
                padding: 5px;
                list-style:none;
                width: 200px;
            }
        </style>
        <script src="angular.js"></script>
        <script>
            var app = angular.module('my-app', [], function () {
            })
            app.controller('AppController', function ($scope) {
            $scope.name = 'World';
            })
        </script>
    </head>

    <body ng-controller="AppController">
        <p>Hello {{name}}!</p>
        <ul>
            <li ng-mouseenter="showXBtn = true;
                                test($event)" ng-mouseleave="showXBtn = false;
                                                    test($event)">
                <p ng-mouseenter="showXBtn = false;" ng-mouseleave="showXBtn = true;
                                    test($event)">Hide</p>
                <button ng-show="showXBtn"><span>x</span></button>
            </li>
        </ul>
        {{showXBtn}}
    </body>
</html>

我使用 AngularJS v1.2.5。这是官方报告的错误吗?或者也许我的chrome出了问题..我有最新版本38.0.2125.111 m。感谢您的任何建议。

最佳答案

我在 Chrome 上遇到了类似的问题,最终将该问题追溯到特定的 Chrome 扩展程序(对我来说,它是 AngularJS Batarang 扩展程序)。

如果您有任何 javascript 分析扩展,添加到页面的速度缓慢有时会导致事件(特别是 mouseenter 和 mouseleave 事件)出现异常行为。

关于jquery - Angular mouseenter 在 Chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26735514/

相关文章:

jquery - 如何使用 CSS 基于 int 值创建动态水平线?

javascript - 在 Vue 项目中使用 jQuery 是否更可取?

javascript - AngularJS中的页面完成事件

angularjs - NgMaterial/Material Design 涟漪效应正在渗透边缘

javascript - 使用 `document.currentScript.ownerDocument.createElement` 创建的图像(从 <link> 导入的 HTML)永远不会加载

html - 从 Media query xs chrome 和 firefox 接收 CSS 时出现问题

jquery - 基于鼠标位置的平滑滚动(Jquery)

css - jQuery:在单击事件中将 css 应用于图像

angularjs:从服务返回json数据到 Controller

javascript - slider 图像需要一些时间来加载。