Javascript 在区间内调用函数会导致;未捕获类型错误:这是.“FunctionName不是函数”;在我的JS文件中

Javascript 在区间内调用函数会导致;未捕获类型错误:这是.“FunctionName不是函数”;在我的JS文件中,javascript,magento2,Javascript,Magento2,我试图在我的JS文件中设置一个间隔,并从其中调用一个函数。然而,我在试图从区间内调用函数时出错。这是我的密码: 注意:我触发\u testFunction()以启动文档顶部的链 _testFunction3: function(){ console.log("Test Function 3 Hit"); }, _testFunction2: function(){ console.log("Test Function 2 Hit"); },

我试图在我的JS文件中设置一个间隔,并从其中调用一个函数。然而,我在试图从区间内调用函数时出错。这是我的密码:

注意:我触发
\u testFunction()
以启动文档顶部的链

_testFunction3: function(){
    console.log("Test Function 3 Hit");
},
_testFunction2: function(){
    console.log("Test Function 2 Hit");
},
_testFunction: function(){
    console.log("Test Function 1 Hit");
    this._testFunction2();
    var timer = null;
    timer = setInterval(function(){
        this._testFunction3();
    }, 1000);
},
预期结果:

控制台日志记录如下:

  • 测试功能1命中
  • 测试功能2命中
  • 测试功能3命中(每1秒一次)
实际结果:

控制台日志记录如下:

  • 测试功能1命中
  • 测试功能2命中
  • 未捕获类型错误:此.\u testFunction3不是函数
我尝试了很多方法,但都无法成功…

这对你有帮助吗

function\u testFunction3(){
日志(“测试功能3命中”);
}
函数_testFunction2(){
日志(“测试功能2命中”);
}
函数_testFunction(){
console.log(“测试功能1命中”);
这是._testFunction2();
var定时器=null;
定时器=设置间隔(此._testFunction3,1000);
}
_testFunction()