Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Can';t调用此内部箭头函数_Javascript_Angular_Function_Typescript_Ionic Framework - Fatal编程技术网

Javascript Can';t调用此内部箭头函数

Javascript Can';t调用此内部箭头函数,javascript,angular,function,typescript,ionic-framework,Javascript,Angular,Function,Typescript,Ionic Framework,当我试图通过此关键字访问时出现问题。我需要访问run函数中的updateTime export class PlayerService { createPlayer(): void { return new window['YT'].Player(this.youtube.playerId, { height: this.youtube.playerHeight, width: this.youtube.

当我试图通过
关键字访问时出现问题。我需要访问
run
函数中的
updateTime

export class PlayerService {

 createPlayer(): void {
            return new window['YT'].Player(this.youtube.playerId, {
                height: this.youtube.playerHeight,
                width: this.youtube.playerWidth,

                events: {
                    'onStateChange': (event) => {

                        function updateTime() {

                   //////I need to access | run function | from here 

                        };

                        this.timeupdater = setInterval(updateTime, 100);


                    }
                }
            });
        }

           run (){

    //some codes 



                }
}

我正在研究离子2

你需要一直使用箭头功能

function updateTime() {
应该是

var updateTime = () => {
setInterval(() => updateTime(), 100);

应该是

var updateTime = () => {
setInterval(() => updateTime(), 100);

您能否更新您的问题以显示所有代码和故障?请确保使用箭头函数作为
updateTime
aswell@Bergi是的,这就是问题所在,我以前不知道这一点(问题是我必须在两者中使用箭头),但我不明白这是如何可以复制的问题?你的批改题与此无关:)@当然是。它解释了(所有方式)如何访问函数(如
updateTime
)中的
this
值,该函数作为对某个对象的回调传递(
setTimeout
),以及为什么它不能与
函数一起工作。我有语法错误。请发布准确和完整的错误。试试我更新的答案。很高兴听到你能让它工作。对于同一个问题,已经有大约5千个问题,因此有些人失去了耐心;-)“和”应该是“或”