how do I setInterval to call a function within a class

前端 未结 3 1600
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-02 17:03

I have a class like:

function run(){
this.interval;
this.start = function(){
    this.interval = setInterval(\'this.draw()\',1000);
};
this.draw = function()         


        
3条回答
  •  时光说笑
    2021-01-02 17:13

    The bind() method!

    See the following example in ES6:

    
    
    
    
        
    
        
    
        
    
    
    

提交回复
热议问题