PromiseRejectionEvent.promise
PromiseRejectionEvent
インターフェイスの promise
は読み取り専用プロパティで、拒否された JavaScript の Promise
を表します。プロミスが拒否された理由は、イベントの PromiseRejectionEvent.reason
プロパティを検査することでわかります。
値
拒否されて、処理されていない JavaScript の Promise
です。
例
この例では処理されておらず、 reason
の code
項目が "Module not ready" であるオブジェクトであるプロミスを待ち受けし、正しい実行に失敗するタスクを再実行する何もしないコールバックをセットアップします。
event.preventDefault()
はプロミスが処理されたことを示すために呼ばれます。
js
window.onunhandledrejection = (event) => {
if (event.reason?.code === "Module not ready") {
requestIdleCallback((deadline) => {
loadModule(event.reason.moduleName).then(performStartup);
});
event.preventDefault();
}
};
仕様書
Specification |
---|
HTML # dom-promiserejectionevent-promise |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
promise |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.