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

点赞(0)

评论列表 共有 0 评论

暂无评论

微信服务号

微信客服

淘宝店铺

support@elephdev.com

发表
评论
Go
顶部