를 추가 한 후 어떻게 Test
개체의 events
건물 내부의 루트 this
에 액세스 할 수 있습니다프로토 타입 상속 문제 이벤트 리스너
"use strict";
var Test = function (element, options) {
};
Test.prototype = {
constructor: Test,
events: {
handleEvent: function (event) {
// this.setup() should point to the Test.prototype.setup property
},
start: function (event) {
}
},
setup: function() {
}
};
나는 요소에 이벤트 리스너를 추가하려면 다음 구문을 사용 후 :
를document.getElementById.addEventListener("touchmove", this.events, false);
this.events
은 Test
개체를 나타냅니다. 테스트를 마치면 this
이 events
개체가 될 것으로 나타났습니다. 어떻게 이런 방식으로 코드를 수정하여 events
객체의 속성 내에서 루트 객체를 사용할 수 있습니까?
나는이 동작을 만들 수 없기 때문에'handle'의 모든 props를'Test' 객체의 루트에 놓았습니다. – Roland