my.onUnhandledRejection
Listen for the unhandledrejection event. The unhandledrejection event is triggered when a JavaScript Promise
that has no rejection handler is rejected. The triggered time of the callback for the unhandledrejection event and required parameters are the same with those of the onUnhandledRejection() method.
Sample code
copy
//.js
App({
onShow(options) {
my.onUnhandledRejection((res) => {
console.log(res.reason);
console.log(res.promise);
});
}
})
Parameters
Property | Type | Description |
callback | Function | The unhandledrejection event is triggered when a JavaScript |
Callback function
Property | Type | Description |
reason | String | Rejection reason, which usually is the error object. |
promise | Promise | The rejected Promise object. |