Skip to content

Commit 52adb3a

Browse files
TYRMarsgitbook-bot
authored andcommitted
GitBook: [master] one page modified
1 parent e83129a commit 52adb3a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

09/promise.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1+
---
2+
description: Promise 使用
3+
---
4+
15
# Promise
26

7+
## Promise简介
8+
9+
Promise 对象用于表示一个异步操作的最终完成(或失败)及其结果值
10+
11+
```javascript
12+
const myFirstPromise = new Promise((resolve, reject) => {
13+
// ?做一些异步操作,最终会调用下面两者之一:
14+
//
15+
// resolve(someValue); // fulfilled
16+
// ?或
17+
// reject("failure reason"); // rejected
18+
});
19+
```
20+
21+
{% hint style="info" %}
22+
promise.finally\(\) 要注意浏览器兼容性
23+
{% endhint %}
24+
25+
## Promise原型
26+
27+
{% code title="hello.sh" %}
28+
```bash
29+
# Ain't no code for that yet, sorry
30+
echo 'You got to trust me on this, I saved the world'
31+
```
32+
{% endcode %}
33+
34+
35+

0 commit comments

Comments
 (0)