除了显示chrome开发人员时,我有一些可以正常工作的javascript代码。有了这个我得到Unable to preventDefault inside passive event listener due to target being treated as passive
代码如下:
function moveDown(event,subnavs){
const navbar = document.getElementsByClassName('main-navigation')[0]
const purpleDiv = document.getElementsByClassName('home-vision')[0]
console.log(navbar,subnavs,purpleDiv)
var menu = document.getElementById("menu-1")
console.log(menu)
console.log(event)
console.log(event.target)
var x= "250px"
purpleDiv.style.marginTop = x
}
(function(){
const subnavs = document.getElementsByClassName('sub-menu')
for (let i = 0; i < subnavs.length; i++) {
subnavs[i].addEventListener('mouseover', function(event) {
moveDown(event, subnavs);
}, {passive: false});
}
})()