how do I setInterval to call a function within a class

前端 未结 3 1621
爱一瞬间的悲伤
爱一瞬间的悲伤 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:16

    function run(){
        this.interval;
        this.start = function(){
            this.interval = setInterval(this.draw,1000);
        };
        this.draw = function(){
            //some code
        }
    ;} 
    
    var run = new run();
    run.start();
    

提交回复
热议问题