[ExtJS3.2源码每天一小时](之九)补充:示例

本文介绍了ExtJS中几个常用函数的实际应用案例,包括拦截器的使用、回调函数的创建方式及其区别、顺序执行函数的构造及延迟执行函数的设置等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[color=red]拦截器示例:[/color]


var testFunc = function(a){
alert('executing...'+a);
}
var func = testFunc.createInterceptor(
function(){alert('intercepted');}
);
testFunc();//拦截器不会生效
func();//拦截器生效,所以必须使用createInterceptor返回的新函数去执行才能实现拦截,这与extjs的内部实现是吻合的



[color=red]创建回调简单示例1:[/color]

var testFunc = function(a){
alert('executing...'+a);
}
//创建一个回调函数
var callFunc = testFunc.createCallback('adsadfsf');

callFunc();//打出 executing...adsadfsf


[color=red]创建回调简单示例2 (与1的区别 另有博文说明):[/color]

var testFunc = function(a){
alert('executing...'+a);
}
//创建一个回调函数
var callFunc = testFunc.createDelegete(window,['adsadfsf']);
callFunc();//打出 executing...adsadfsf


[color=red]创建一个顺序执行的函数:[/color]

var testFunc = function(a){
alert('executing...'+a);
}
//创建一个回调函数
var callFunc = testFunc.createSequence(funciton(a){
alert('executing...2'+a);
});
callFunc();//打出 executing...adsadfsf 后接着打出 executing2...adsadfsf



[color=red]创建一个延迟执行的函数:[/color]

var testFunc = function(a){
alert('executing...'+a);
}
//window指作用域 ['haha']传入参数数组
testFunc.defer(2000,window,['haha'],true);//打出 executing...haha
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值