-3
var MyClass = function() {
//some functionality goes here
};
MyClass.prototype.xyz = function() {
//some functionality goes here
};
MyClass.prototype.abc = function() {
var self = this;
// here self is not working and 'this.xyz()' isn't working too.
self.xyz();
// It works if I use MyClass.prototype.xyz();
};
有人可以帮助我在这里失踪吗?在原型中引用'this'不起作用
添加**完成**代码。 – Tushar
可能是[如何在回调中访问正确'this'的副本](http://stackoverflow.com/q/20279484/218196) –
“this'的值取决于**而不是**定义你的功能,但是你如何调用你的功能。既然你不显示你如何调用函数'abc',我们不能帮你 – slebetman