mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-28 21:32:20 +00:00
docs(promise): edit promise
This commit is contained in:
parent
9ecf067ddf
commit
cc2e6cac36
@ -179,7 +179,7 @@ p2
|
||||
// Error: fail
|
||||
```
|
||||
|
||||
上面代码中,`p1`是一个Promise,3秒之后变为`rejected`。`p2`的状态在1秒之后改变,`resolve`方法返回的是`p1`。此时,由于`p2`返回的是另一个Promise,所以后面的`then`语句都变成针对后者(`p1`)。又过了2秒,`p1`变为`rejected`,导致触发`catch`方法指定的回调函数。
|
||||
上面代码中,`p1`是一个Promise,3秒之后变为`rejected`。`p2`的状态在1秒之后改变,`resolve`方法返回的是`p1`。由于`p2`返回的是另一个 Promise,导致`p2`自己的状态无效了,由`p1`的状态决定`p2`的状态。所以,后面的`then`语句都变成针对后者(`p1`)。又过了2秒,`p1`变为`rejected`,导致触发`catch`方法指定的回调函数。
|
||||
|
||||
## Promise.prototype.then()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user