PromiseRejectionEvent.promise - Web APIs 编辑
The PromiseRejectionEvent
interface's promise
read-only property indicates the JavaScript Promise
which was rejected. You can examine the event's PromiseRejectionEvent.reason
property to learn why the promise was rejected.
Syntax
promise = PromiseRejectionEvent.promise
Value
The JavaScript Promise
which was rejected, and whose rejection went unhandled.
Examples
This example listens for unhandled promises and, if the reason
is an object with a code
field containing the text "Module not ready", it sets up an idle callback that will retry the task that failed to execute correctly.
event.preventDefault()
is called to indicate that the promise has now been handled.
window.onunhandledrejection = function(event) {
if (event.reason.code && event.reason.code == "Module not ready") {
window.requestIdleCallback(function(deadline) {
loadModule(event.reason.moduleName)
.then(performStartup);
});
event.preventDefault();
}
}
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'PromiseRejectionEvent.promise' in that specification. | Living Standard | Initial definition. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论