代码:consttarget=document.getElementById('target');lete;target.addEventListener('click',function(event){e=event;console.log(e);console.log(e.currentTarget);});控制台输出:MouseEvent {isTrusted:true,screenX:149,screenY:253,clientX:149,clientY:131, …}
然而,在控制台输入:console.log(e);console.log(e.currentTarget);得到的结果却是:VM1656:1MouseEvent {isTrusted:true,screenX:149,screenY:253,clientX:149,clientY:131, …}VM1656:2null显然,event对象是相同的,但是为什么控制台输出currentTarget是null?从控制台查看event对象中的currentTarget,其值是null,那为什么js文件中输出的currentTarget不是null?
Qyouu
相关分类