【问题标题】:Uncaught TypeError: Cannot read properties of undefined (reading 'querySelectorAll')at Number.handleHover未捕获的类型错误:无法在 Number.handleHover 读取未定义的属性(读取 \'querySelectorAll\')
【发布时间】:2022-11-25 02:33:43
【问题描述】:

我有一些 JavaScrupt 代码给出了这个错误 Uncaught TypeError: Cannot read properties of undefined (reading 'querySelectorAll')at Number.handleHover .

 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));

【问题讨论】:

    标签: javascript typeerror undefined selectors-api


    【解决方案1】:

    嗯,你应该删除sibling中的“document”。

    【讨论】:

      猜你喜欢
      • 2018-01-26
      • 2015-08-19
      • 2021-12-22
      • 2021-12-25
      • 2021-11-24
      • 2021-10-31
      • 2021-11-07
      • 2022-01-17
      • 2023-03-13
      相关资源
      最近更新 更多