gpt4 book ai didi

WordPress 将被动监听器设置为主动

转载 作者:行者123 更新时间:2023-12-02 23:41:53 25 4
gpt4 key购买 nike

我有一个 WordPress 网站,在使用 Chrome 的开发者控制台中收到以下错误:

[Intervention] Unable to preventDefault inside passive event listener due to 
target being treated as passive.

我有一个 javascript 片段,我在其中设置了 4 个监听器:

function moveDown(){                    
const submenus = document.getElementsByClassName('sub-menu')
var navbar = document.getElementById("menu-1");
var sub = this.getElementsByTagName('ul')[0]
var rect = sub.getBoundingClientRect();
navbar.style.marginBottom = rect.height + "px"
}


function moveUp(event){
var navbar = document.getElementById("menu-1");
navbar.style.marginBottom = 0
}


(function(){
var takeAction = document.getElementsByClassName('takeAction')[0]
var aboutUs = document.getElementsByClassName('aboutUs')[0]


aboutUs.addEventListener('mouseover', moveDown,{passive: false})
takeAction.addEventListener('mouseover', moveDown,{passive: false})

aboutUs.addEventListener('mouseleave', function(event) {moveUp(event)},{passive: false})
takeAction.addEventListener('mouseleave', function(event) {moveUp(event)},{passive: false})


})()

由于我已经在每个监听器上设置了 {passive:false},我该如何解决这个问题?

最佳答案

问题已经消失。看起来像是一个 WordPress 的东西,但谁知道呢

关于WordPress 将被动监听器设置为主动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58468510/

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