1、因为如果不用try/catch 包起来,如果遇到连不上接口的情况,就会只在控制台输出信息,前台收不到报错信息
try{ var response = await $.ajax({type: 'POST',url: url,data: null,contentType: "application/json;charset=UTF-8",dataType: "json"}) if (response.code == 200) { const itemId = response.data.problemCode createIssue(data,itemId,ctx) } else { msg.showError("获取项目流水码失败,失败原因:"+response.message) return false } }catch(errorMsg){ msg.showError("获取项目流水码失败,请联系管理员!") condition.is_sumbit=true }
标签:接口,try,ajax,catch,data,response From: https://www.cnblogs.com/wwssgg/p/17614461.html