大佬教程收集整理的这篇文章主要介绍了javascript – MooTools的隐藏功能,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
// define the mutator as 'Monitor',use as Mointor: ['methodname','method2'...] Class.Mutators.Monitor = function(methods){ if (!this.prototype.initializE) this.implement('initialize',function(){}); return Array.from(methods).concat(this.prototype.Monitor || []); }; Class.Mutators.initialize = function(initializE){ return function(){ Array.from(this.Monitor).each(function(Name){ var original = this[name]; if (original) this[name] = function() { console.log("[LOG] " + name,"[SCOPE]:",this,"[ARGS]",arguments); original.apply(this,arguments); } },this); return initialize.apply(this,arguments); }; };@H_@R_801_11248@_2@然后在类中:
var foo = new Class({ Monitor: 'bar',initialize: function() { this.bar("mootools"); },bar: function(what) { alert(what); } }); var f = new foo(); f.bar.call({hi:"there from a custom scope"},"scope 2");@H_@R_801_11248@_2@尝试jsfiddle:http://jsfiddle.net/BMsZ7/2/ @H_@R_801_11248@_2@这个小宝石一直有助于我在一个HUUUGE异步webapp中捕获嵌套的bugfoot竞争条件问题,否则会很难跟踪.
以上是大佬教程为你收集整理的javascript – MooTools的隐藏功能全部内容,希望文章能够帮你解决javascript – MooTools的隐藏功能所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。