源码看这里Promise.prototype.then=function(onFulfilled,onRejected){if(this.constructor!==Promise){returnsafeThen(this,onFulfilled,onRejected);}varres=newPromise(noop);handle(this,newHandler(onFulfilled,onRejected,res));returnres;};functionsafeThen(self,onFulfilled,onRejected){returnnewself.constructor(function(resolve,reject){//以下不是很理解varres=newPromise(noop);res.then(resolve,reject);handle(self,newHandler(onFulfilled,onRejected,res));});}
添加回答
举报
0/150
提交
取消