then方法的實現裏,確實是返回了壹個新的Promise,妳說的double,其實是then的第壹個參數onFulfilled。this.then=function(onFulfilled,onRejected){varself=this;returnnewPromise(function(resolve,reject){returnself.done(function(result){if(typeofonFulfilled==='function'){try{returnresolve(onFulfilled(result));}catch(ex){returnreject(ex);}}else{returnresolve(result);}},function(error){if(typeofonRejected==='function'){try{returnresolve(onRejected(error));}catch(ex){returnreject(ex);}}else{returnreject(error);}});});}
上一篇:小楷是什麽軟件?下一篇:jQuery wordexport導出word 手機打開亂碼