my.onComponentError
Updated at:
Registers a listener for JavaScript errors thrown inside Mini Program custom components.
Description
my.onComponentError listens for error events in the JavaScript code of Mini Program custom components. When JavaScript code in a custom component throws an error, the my.onComponentError callback runs, and the my.onError callback is also triggered.
Input parameter
Function listener
Parameter
|
Attribute |
Node type |
Description |
|
error |
Error |
The exception object. |
|
method |
String |
The custom component method where the exception occurred. |
|
component |
Component |
The custom component instance where the exception occurred. |
Sample code
my.onComponentError(Function listener)
Page({
onLoad() {
my.onComponentError(this.errorHandler);
},
errorHandler(error, method, component) {
console.log('onComponentError res', error);
console.log('onComponentError stack', method);
console.log('onComponentError component', component);
}
})
Is this page helpful?