gpt4 book ai didi

javascript - Angularjs 鼠标进入事件

转载 作者:行者123 更新时间:2023-11-29 21:54:30 26 4
gpt4 key购买 nike

我想更改 ng-mouse enter 事件,以便只有当用户在现场停留超过一秒钟时,事件才会触发似乎 ng-model-options="{ debounce: 1000 }" 不适用于此事件

有什么想法吗?

最佳答案

<button ng-mouseenter="myEvent()" ng-mouseleave="myEvent2()" > </button>


$scope.flag=false;
$scope.myEvent = function() {
$scope.flag=true;
$timeOut(function(){


if($scope.flag)
{
// do your logic here

}
}, 1000);
}

$scope.myEvent2 = function() {
$scope.flag=false;
}

在这里你可以在mouseenter上设置超时,并检查flag是否因鼠标离开而变为false,这个逻辑只有在用户没有离开时才会执行mouseleave 完成 1 秒

关于javascript - Angularjs 鼠标进入事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27164526/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com