当前位置 : 主页 > 网页制作 > Dojo >

dojo小例子(25)在循环结束后再执行后续语句

来源:互联网 收集:自由互联 发布时间:2021-06-15
var deferred = new Deferred();var index = 0; results.forEach(function( item ){ //results是数组 index ++; if( index === results.length - 1 ){ deferred.resolve(index); }}); deferred.then(function(last){if( last ){button.hidden = false;}els
        var deferred = new Deferred();
	var index = 0;
        results.forEach(function( item ){ //results是数组
        	index ++;
        	if( index === results.length - 1 ){
        		deferred.resolve(index);
        	}
			
	});
        
        deferred.then(function(last){
			
			if( last ){
				button.hidden = false;
			}else{
				button.hidden = true;
			}
		});
网友评论