javascript anonymous function parameter passing

后端 未结 5 543
终归单人心
终归单人心 2021-02-02 13:04

I have some javascript code (within an object) :

toggle: function() {
    var me = this;
    var handler = function() { me.progress() };
    me.intervalId = setI         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 13:25

    Have you tried to return the function like this?

    var handler = function(o){
       return function(){
          o.progress();
       }
    }(me);
    

    Now you can call:

    handler();
    

提交回复
热议问题