无法从Node JS中的另一个箭头函数调用箭头函数

Can't call arrow function from another arrow function in Node JS

考虑代码:

module.exports = class SuperGenerator {
    Generate = packageId => {

        // ... 
        TestMe();

    }


    TestMe = () => {
        console.log("Test Me...");
    };  

}

当我 运行 时,代码 TestMe 未被调用。

为什么?

如果简单 TestMe()

,您需要调用 this.TestMe()

所以有几件事。如果你在谈论 class 函数,那么你需要用 this 调用它们(例如 this.TestMe()),但如果你在谈论两个函数表达式,它们不会被提升,所以你'在你想使用它们之前,你必须先定义它们。