-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[zh-CN]: update the translation of the promise #27965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
files/zh-cn/web/javascript/reference/global_objects/promise/index.md
Outdated
Show resolved
Hide resolved
Preview URLs External URLs (1)URL:
(comment last updated: 2025-07-07 01:27:41) |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
files/zh-cn/web/javascript/reference/global_objects/promise/index.md
Outdated
Show resolved
Hide resolved
files/zh-cn/web/javascript/reference/global_objects/promise/index.md
Outdated
Show resolved
Hide resolved
|
||
`.then()` 方法最多接受两个参数;第一个参数是 Promise 兑现时的回调函数,第二个参数是 Promise 拒绝时的回调函数。每个 `.then()` 返回一个新生成的 Promise 对象,这个对象可被用于链式调用,例如: | ||
{{jsxref("Promise.prototype.then()")}}、{{jsxref("Promise.prototype.catch()")}} 和 {{jsxref("Promise.prototype.finally()")}} 方法用于将进一步的操作与已敲定的 Promise 相关联。`.then()` 方法最多接受两个参数;第一个参数是 Promise 兑现时的回调函数,第二个参数是 Promise 拒绝时的回调函数。`.catch()` 和 `.finally()` 方法在内部调用 `.then()`,使错误处理更加简洁。例如,`.catch()` 实际上就是一个没有传递兑现处理器的 `.then()`。由于这些方法返回 Promise,因此它们可以被链式调用。例如: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{{jsxref("Promise.prototype.then()")}}、{{jsxref("Promise.prototype.catch()")}} 和 {{jsxref("Promise.prototype.finally()")}} 方法用于将进一步的操作与已敲定的 Promise 相关联。`.then()` 方法最多接受两个参数;第一个参数是 Promise 兑现时的回调函数,第二个参数是 Promise 拒绝时的回调函数。`.catch()` 和 `.finally()` 方法在内部调用 `.then()`,使错误处理更加简洁。例如,`.catch()` 实际上就是一个没有传递兑现处理器的 `.then()`。由于这些方法返回 Promise,因此它们可以被链式调用。例如: | |
{{jsxref("Promise/then", "then()")}}、{{jsxref("Promise/catch", "catch()")}} 和 {{jsxref("Promise/finally", "finally()")}} 方法用于将进一步的操作与已敲定的 Promise 相关联。`.then()` 方法最多接受两个参数;第一个参数是 Promise 兑现时的回调函数,第二个参数是 Promise 拒绝时的回调函数。`.catch()` 和 `.finally()` 方法在内部调用 `.then()`,使错误处理更加简洁。例如,`.catch()` 实际上就是一个没有传递兑现处理器的 `.then()`。由于这些方法返回 Promise,因此它们可以被链式调用。例如: |
另一个使用 `Promise` 和 {{domxref("XMLHttpRequest")}} 加载图像的示例如下所示。 | ||
每一步都有注释,可以让你详细了解 Promise 和 XHR 架构。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另一个使用 `Promise` 和 {{domxref("XMLHttpRequest")}} 加载图像的示例如下所示。 | |
每一步都有注释,可以让你详细了解 Promise 和 XHR 架构。 | |
另一个使用 `Promise` 和 {{domxref("XMLHttpRequest")}} 加载图像的示例如下所示。每一步都有注释,可以让你详细了解 Promise 和 XHR 架构。 |
每一步都有注释,可以让你详细了解 Promise 和 XHR 架构。 | ||
|
||
```html hidden live-sample___promises | ||
<h1>Promise example</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<h1>Promise example</h1> | |
<h1>Promise 示例</h1> |
@@ -449,4 +511,4 @@ btn.addEventListener("click", testPromise); | |||
- [使用 promise](/zh-CN/docs/Web/JavaScript/Guide/Using_promises) | |||
- [Promises/A+ 规范](https://promisesaplus.com/) | |||
- [JavaScript Promise:简介](https://web.developers.google.cn/articles/promises) | |||
- [Domenic Denicola:回调、Promise 和协程——JavaScript 中的异步编程模式](https://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript) | |||
- [回调、Promise 和协程——JavaScript 中的异步编程模式](https://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [回调、Promise 和协程——JavaScript 中的异步编程模式](https://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript) | |
- Domenic Denicola 的幻灯片演示(2011):[回调、Promise 和协程——JavaScript 中的异步编程模式](https://www.slideshare.net/domenicdenicola/callbacks-promises-and-coroutines-oh-my-the-evolution-of-asynchronicity-in-javascript) |
Description
As the title.
Motivation
Ditto.
Additional details
Nope.
Related issues and pull requests