javascript - How does js catch an asynchronous error like Uncaught (in promise) TypeError?
迷茫
迷茫 2017-07-05 10:59:52
0
1
1485

1. Try to use window.onerror to capture this unknown asynchronous error, but it fails and is not detected at all. Question: Is onerror unable to detect this kind of asynchronous error?
2. Because the error is reported in the vue module file, try-catch cannot be used to wrap the captured error. So is there any way to detect it? As shown below, an asynchronous error in the vue module occurred when switching routes (the vue array elements were continuously updated before routing switching)...

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
为情所困

Add catch at the end of the Promise instance to catch errors

The PromiseA+ specification does not include the Promise.prototype.catch method. This method is written in the ES6 specification. You can call the catch method in the instance to catch errors. You can directly catch all errors in the last step of the promise instance

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template