我有以下模块Dog
。我想在每次拨打wagTail()
时拨打会员功能walk()
,因为这是一条快乐的狗。
class Dog {
constructor(name){
this.name = name
}
walk(){
doAsyncStuffToMoveLegs((error) => {
if(!error) {
this.wagTail()
}
})
}
wagTail(){
// initiate tail wagging :)
}
}
module.exports = {Dog: Dog}
我收到以下错误:
TypeError: Cannot read property 'wagTail' of undefined.
我做错了什么?