Did you know that you can use window.error to catch and report global JavaScript errors?

window.addEventListener('error', function(event) {
   console.log('Captured error:', event);
});

In the error object, you will get all kinds of information, including error messages, target elements, and even stack traces

image.png

This is how many error logging platforms capture client errors: event listeners can be added globally, callbacks can send the error date to the server, and you can use it for various things there

Likes(0)

Comment list count 0 Comments

No Comments

WeChat Self-Service

WeChat Consult

TaoBao

support@elephdev.com

发表
评论
Go
Top