猛跑小猪
改成这样就行了var timeline = [ function() { return new Promise(function(resolve, reject) { setTimeout(function() { resolve('task5<br>'); }, 1000); }); }, function() { return new Promise(function(resolve, reject) { setTimeout(function() { resolve('task6<br>'); }, 1500); }); }, function() { return new Promise(function(resolve, reject) { setTimeout(function() { resolve('task7<br>'); }, 2000); }); }, function() { return new Promise(function(resolve, reject) { setTimeout(function() { resolve('task8<br>'); }, 800); }); } ]; // 完成后立刻输出结果,但是按照顺序输出 timeline.map(function(val) { return val(); }).reduce(function(init, req) { return init.then(function() { return req; }).then(function(result){ document.writeln(result) }) }, Promise.resolve());