1 var proxy = function(func, thisObject) {
 2         return (function() {
 3             return func.apply(thisObject, arguments);
 4         });
 5     };
 6 
 7 //example
 8 var clicky = {
 9     wasClicked: function() {},
10     addListeners: function() {
11         var self = this;
12         $('.clicky').click(proxy(this.wasClicked, this));
13     }
14 };

JQ也有这个方法

相关文章:

  • 2021-08-06
  • 2021-08-16
  • 2022-02-12
  • 2021-09-07
  • 2021-08-28
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-07
  • 2021-10-03
  • 2022-12-23
  • 2021-10-31
  • 2021-12-04
  • 2021-12-23
  • 2021-04-26
相关资源
相似解决方案