在我的一个LoopBack模型中,我想向模型添加一个实例方法,但它不会让我访问this,因为this在prototype方法中未定义:
module.exports = (MyModel) => {
MyModel.prototype.doStuff = () => {
console.log(this); // outputs undefined
}
}
Run Code Online (Sandbox Code Playgroud)
这显然限制了实例方法的有用性.有没有办法做到这一点?