Javascript未捕获的TypeError:无法读取属性'querySelector'

时间:2020-06-27 10:24:56

标签: javascript


function globalNavPopup(e) {
    var t = this,
        n = Strut.touch.isSupported ? "touchend" : "click";
    this.activeClass = "globalPopupActive", this.root = document.querySelector(e), this.link = this.root.querySelector(".rootLink"), this.popup = this.root.querySelector(".popup"), this.closeButton = this.root.querySelector(".popupCloseButton"), this.link.addEventListener(n, function(e) {
        e.stopPropagation(), t.togglePopup()
    }), this.popup.addEventListener(n, function(e) {
        e.stopPropagation()
    }), this.closeButton && this.closeButton.addEventListener(n, function(e) {
        t.closeAllPopups()
    }), document.body.addEventListener(n, function(e) {
        Strut.touch.isDragging || t.closeAllPopups()
    }, !1)
}

出现错误:

Uncaught TypeError: Cannot read property 'querySelector' of null
    at new globalNavPopup (script.js:48)
    at HTMLDocument.<anonymous> (script.js:244)

注意:这是我要修复的笔https://codepen.io/JakeHenshall/pen/ZBvLgG

0 个答案:

没有答案