그래서, 같은 코드가 처리 할 때 올바른 객체를 얻기 :자바 스크립트 : 이벤트
function Shape() {
...
var canvas = document.getElementById('canvas');
...
canvas.onmousedown = handleMouseDown;
}
function handleMouseDown(e) {
this.width // Doesn't refer to the shape
// How do I get a reference to the shape here?
}
질문 - 어떻게 내 이벤트 핸들러의 모양에 대한 참조를받을 수 있나요?
HandleMouseDown? 'e'가 모양을 말하는 이유는 무엇입니까? 마우스 이벤트를 처리하기위한 고유 한 함수를 만들어야합니다. – Cristy