1、我这样await的话,会没有等到queryEnv 执行完,就直接返回了response
export let load = async function (data) { let response = await queryEnv(url,uidJson).data; return response; } async function queryEnv (url,uid) { var response = await $.ajax({ type: 'POST', url: url, data: JSON.stringify(uid), contentType: "application/json;charset=UTF-8", dataType: "json", }) console.log("response = " + response); return response; }
2、我将两个方法,并到一个方法,就没有问题
export let load = async function (data) { let response = await $.ajax({ type: 'POST', url: url, data: JSON.stringify(uidJson), contentType: "application/json;charset=UTF-8", dataType: "json", }) return response; }
疑问:为啥,查分成两个方法,await就不会阻塞了?
标签:url,await,阻塞,json,let,无法,data,response From: https://www.cnblogs.com/wwssgg/p/17648562.html