Angular mouseenter在Chrome中不起作用
问题描述:
我正在为Angular编写我的第一个应用程序,并且我遇到了mouseenter事件的问题。它根本不适用于Chrome。首先,我认为我的代码中有一个错误,但我在Firefox中检查过它,一切正常。我决定从jsfiddle中用mouseenter测试一些代码,它看起来是一样的 - 在Firefox上没问题,在Chrome上没有 - 在mouseenter之后没有任何反应。Angular mouseenter在Chrome中不起作用
测试代码:
<!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。这是官方报告的错误吗?或者,也许与我的铬是错误的..我有最新版本38.0.2125.111米。感谢您的任何建议。
答
我和Chrome有类似的问题,并最终将问题追踪到特定的Chrome扩展程序(对我而言,扩展名为AngularJS Batarang)。
如果您有任何JavaScript分析扩展,那些添加到页面的缓慢时有时会导致事件(特别是mouseenter和mouseleave事件)中的异常行为。
http://jsfiddle.net/arunpjohny/epz2dd9b/2/ – 2014-11-04 12:52:25
Chrome仅在单击元素时才会作出反应 – elevenMinutes 2014-11-04 12:55:09
Chrome出现问题,因为它按预期工作。 – dfsq 2014-11-04 12:56:03