未捕获的类型错误:无法读取未定义的属性(读取"querySelectorAll")在 Number.handleHover



我有一些JavaScrupt代码给出了这个错误Uncaught TypeError:无法读取Number.handleHover上未定义的属性(读取'querySelectorAll'(.

const handleHover = function (e) {
if (e.target.classList.contains('nav-link')) {
const link = e.target;
const sibling = link
.closest('.nav-wrap')
.document.querySelectorAll('.nav-link');
sibling.forEach(el => {
if (el !== link) el.style.opacity = this;
});
}
};
navSmooth.addEventListener('mouseover', handleHover.bind(0.5));
navSmooth.addEventListener('mouseout', handleHover.bind(1));

好吧,您应该删除同级中的"document"。

最新更新