单击在移动浏览器上不起作用
Click not working on mobile browsers
我有以下问题 我有
<ul>
<li>
<a href="/">main page</a>
</li>
</ul>
这适用于任何桌面浏览器,但它不会点击 Ipad/Iphone 和 Android。
此问题与您提到的设备(Ipad/Iphone、android 手机)有关。
touchend 事件调用 event.stopPropagation() 因为您无法实现该操作。
要解决您的问题,您有 2 个解决方案:
- 不要把你的代码放在里面
<ul> and <li> and the code will be like that
<div>
<a href="/"> main page</a>
</div>
-第二种解决方案创建一个名为 eventStop 的新指令
<ul>
<li>
<a href="/" stop-event="touchend">main page</a>
</li>
</ul>
指令是
.directive('stopEvent', function() {
return {
restrict: 'A',
link: function(scope, element, attr) {
element.on(attr.stopEvent, function(e) {
e.stopPropagation();
});
}
};
});
我有以下问题 我有
<ul>
<li>
<a href="/">main page</a>
</li>
</ul>
这适用于任何桌面浏览器,但它不会点击 Ipad/Iphone 和 Android。
此问题与您提到的设备(Ipad/Iphone、android 手机)有关。 touchend 事件调用 event.stopPropagation() 因为您无法实现该操作。 要解决您的问题,您有 2 个解决方案: - 不要把你的代码放在里面
<ul> and <li> and the code will be like that
<div>
<a href="/"> main page</a>
</div>
-第二种解决方案创建一个名为 eventStop 的新指令
<ul>
<li>
<a href="/" stop-event="touchend">main page</a>
</li>
</ul>
指令是
.directive('stopEvent', function() {
return {
restrict: 'A',
link: function(scope, element, attr) {
element.on(attr.stopEvent, function(e) {
e.stopPropagation();
});
}
};
});