/** * JS AOP方法拦截方法,只要返回false,后边的方法就不再执行 * 调用示例 : * func = func.before(beforefn).after(afterfn); * func(); */Function.prototype.before = function(beforefn){ var _self = this; return function(){ if(beforefn.apply(this,arguments) === false){ return false; } return _self.apply(this,arguments); }}Function.prototype.after = function(afterfn){ var _self = this; return function(){ var ret = _self.apply(this,arguments); if(ret === false){ return false; } afterfn.apply(this,arguments); return ret; }}