my.offUnhandledRejection

Unlisten for the unhandledrejection event.

Sample code

copy
//.js
App({
  onShow(options) {
    const handleRejection = (res) => {
      console.log(res.reason);
      console.log(res.promise);
    }
    my.onUnhandledRejection(handleRejection);
    my.offUnhandledRejection(handleRejection);
  }
})

Parameters

PropertyTypeDescription

callback

Function

The unhandledrejection event is triggered when a JavaScript Promise that has no rejection handler is rejected.