fix: 修复手写Promise中_changeState方法的bug
This commit is contained in:
parent
bb56b128cb
commit
442c9c8c16
@ -161,6 +161,12 @@ class MyPromise {
|
||||
// 目前状态已经更改
|
||||
return;
|
||||
}
|
||||
// 下面这个判断是为了处理value为Promise的情况
|
||||
// 这一段代码课程中没有涉及,特此注释说明
|
||||
if (isPromise(value)) {
|
||||
value.then(this._resolve.bind(this), this._reject.bind(this));
|
||||
return;
|
||||
}
|
||||
this._state = newState;
|
||||
this._value = value;
|
||||
this._runHandlers(); // 状态变化,执行队列
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user