无法从Node JS中的另一个箭头功能调用箭头功能

问题描述 投票:0回答:2

考虑代码:

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

        // ... 
        TestMe();

    }


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

}

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

为什么?

javascript node.js arrow-functions
2个回答
-1
投票

如果简单this.TestMe(),则需要呼叫TestMe()


-1
投票

如对您的问题的评论中所述,如下定义TestMe

    const TestMe = () => {
        console.log("Test Me...");
    };  
© www.soinside.com 2019 - 2024. All rights reserved.