3
内阅读对象属性(不确定?)当我试图从事件功能onMouveMove我得到以下错误访问对象this.guy:不能实例
"Uncaught TypeError: Cannot read property 'prop1' of undefined"
当我检查Chrome的Devtool,价值存在并存在,它只是无法识别“onMouseMove”功能。
MyClass = function(some_html_element){
this.guy = {"prop1":[]};
some_html_element.onmousemove = this.onMouseMove;
}
MyClass.prototype.onMouseMove = function(evt){
if(!this.guy.prop1){ //<- here's the error
alert("no error");
}
}
a = new MyClass(document.querySelector("#example"))
<div id="example">
MOVE MOUSE ON ME
</div>
任何想法?
该死太慢... – Stefan
你应该将其标记为重复,已经有很多的问题,正是这样 –
跆拳道,我现在恨的JavaScript。 谢谢! –