/* * @Author: fanjiahui * @Date: 2018-03-12 */ function cook(){ console.log('开始做饭。'); var p = new Promise(function(resolve, reject){ setTimeout(function(){ console.log('做饭完毕!'); resolve('红烧排骨'); },1000); }); return p; } function eat(food){ console.log('开始吃了:' + food); var p = new Promise(function(resolve, reject){ setTimeout(function(){ console.log('我吃完了!'); resolve('十只空碗'); },2000) }); return p; } cook() .then(eat) .then(function(data){ console.log(data); });