随笔-9  评论-168  文章-266  trackbacks-0

正确:
var f=function(v){return function(){{ Ext.messageBox.updateProgress(i/10,"...","...");}};    //setTimeout第一个参数需要的是函数
for (var i=1;i<11;i++)
setTimeout(f(i),i*500);


错误: 只执行一次或运行错误
for (var i=1;i<11;i++)
setTimeout(function(v){{ Ext.messageBox.updateProgress(i/10,"...","...");),i*500);
//setTimeout(function(v){return function(){{ Ext.messageBox.updateProgress(i/10,"...","...");}},i*500);

此文错误.错在闭包理解上.
正确:
setTimeout((function(v){return function(){{ Ext.messageBox.updateProgress(i/10,"...","...");}})( i ),i*500);
posted on 2009-02-05 12:45 紫蝶∏飛揚↗ 阅读(669) 评论(0)  编辑  收藏 所属分类: EXTJS

只有注册用户登录后才能发表评论。


网站导航: