正確:
var f=function(v){return function(){{ Ext.messageBox.updateProgress(i/10,"...","...");}}; //setTimeout第一個(gè)參數(shù)需要的是函數(shù)
for (var i=1;i<11;i++)
setTimeout(f(i),i*500);
錯(cuò)誤: 只執(zhí)行一次或運(yùn)行錯(cuò)誤
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);
此文錯(cuò)誤.錯(cuò)在閉包理解上.
正確:
setTimeout((function(v){return function(){{ Ext.messageBox.updateProgress(i/10,"...","...");}})( i ),i*500);
posted on 2009-02-05 12:45
紫蝶∏飛揚(yáng)↗ 閱讀(675)
評(píng)論(0) 編輯 收藏 所屬分類:
EXTJS