Removes a listener function for unhandled Promise rejection events.
Description
my.offUnhandledRejection
Removes a listener function for unhandled Promise rejection events.
Input parameter
Function listener
The callback function for unhandled Promise rejection events.
Sample code
my.offUnhandledRejection(Function listener)
Page({
onLoad() {
my.onUnhandledRejection(this.unhandledRejectionHandler);
},
unhandledRejectionHandler(res) {
console.log('onUnhandledRejection reason', res.reason);
console.log('onUnhandledRejection promise', res.promise);
},
offUnhandledRejection() {
my.offUnhandledRejection(this.unhandledRejectionHandler);
}
})
该文章对您有帮助吗?