100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > javascript AOP 实现ajax回调函数使用比较方便【javascript】

javascript AOP 实现ajax回调函数使用比较方便【javascript】

时间:2022-02-12 23:51:33

相关推荐

javascript AOP 实现ajax回调函数使用比较方便【javascript】

web前端|js教程

ajax回调函数

web前端-js教程

即时聊天系统源码php,ubuntu退出tftp,js无法同步到tomcat,爬虫蝎子养殖,php 检测服务器状态,黄江关键词seo优化公司lzw

function actsAsDecorator(object) {

object.setupDecoratorFor = function(method) {

if (! (original_ + method in object) ) {

object[original_ + method] = object[method];

object[efore_ + method] = [ ];

object[after_ + method] = [ ];

object[method] = function() {

var i;

var b = this[efore_ + method];

var a = this[after_ + method];

var rv;

for (i = 0; i < b.length; i++) {

b[i].call(this, arguments);

}

rv = this[original_ + method].apply(this, arguments);

for (i = 0; i < a.length; i++) {

a[i].call(this, arguments);

}

return rv;

}

}

};

object.before = function(method, f) {

object.setupDecoratorFor(method);

object[efore_ + method].unshift(f);

};

object.after = function(method, f) {

object.setupDecoratorFor(method);

object[after_ + method].push(f);

};

}

/**

Invoking

*/

function Test(){

this.say1 = function(s){

alert(s);

}

this.say2 = function(s){

alert(s);

}

}

var t = new Test();

actsAsDecorator(t);

t.before("say1",beforeHander);

t.after("say2",afterHander);

test();

制作卡盟我源码,ubuntu上如何编程,爬虫与软件测试,php漏斗,seo选火星lzw

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。