使用Error和try catch
<script> function p1() { return new Promise(function (resolve, reject) { reject(new Error("网络错误")) }) } async function Getdata() { try { var t1 = await p1(); } catch (e) { console.log(e); } } $(function () { Getdata(); }) </script>
漫思