Cannot read property 'target' of undefined 錯誤提示 chrome瀏覽器
this.el.addEventListener('click',function(event){});
? ? ? ? if( event.target !==this.el){ ? ? //此句報錯
? ? ? ? ? ? self.triggerSwitch();
? ? ? ? }
請問該怎么解決
this.el.addEventListener('click',function(event){});
? ? ? ? if( event.target !==this.el){ ? ? //此句報錯
? ? ? ? ? ? self.triggerSwitch();
? ? ? ? }
請問該怎么解決
2017-01-27
舉報
2017-02-04
報錯 你不能讀取未定義的target屬性
你沒發現event.target不在function(event)函數里嗎
試一下把下面這段放入
? function(event){
if( event.target !==this.el){ ? ? //此句報錯
? ? ? ? ? ? self.triggerSwitch();
? ? ? ? }
}
我也初學 不對勿噴