-
我把一个对象的方法直接当回调传给了 setTimeout 和事件监听,触发时报 Cannot read properties of undefined:一次 JavaScript this 指向丢失、把方法拆离对象就丢了绑定的深度复盘
我写了个 class 管理面板,把方法 handleClick 直接当回调传给按钮的 addEventListener,点击时控制台爆红:Cannot read properties of undefined (reading 'state')。同样的事发生在 setTimeout(panel.refresh, 1000) 上。这方法明明是 panel 的,this 怎么会是 …- 0
- 0
事件监听
幸运之星正在降临...
点击领取今天的签到奖励!
恭喜!您今天获得了{{mission.data.mission.credit}}积分
我的优惠劵
-
¥优惠劵使用时效:无法使用使用时效:
之前
使用时效:永久有效优惠劵ID:×
没有优惠劵可用!

