【发布时间】:2018-05-03 07:23:16
【问题描述】:
我有这种情况
class A {
a(params) {
//some code here
}
b(params) {
//some code here
}
c(params) {
this.a(function(data) {
console.log(this); // undefined
this.b(); // error no function b of undefined
})
}
}
我尝试使用bind(this) 将其绑定到“a”,但它显示无法读取未定义的属性“绑定”或未定义。当我打印这个时,我得到了 A 类。我想在“a”函数中调用它。
【问题讨论】:
标签: javascript node.js function oop