两个 async和await
一、父事件代码
async function WxEdit(wxValue,wxShcompany) {let ifDate = await SelectWx(wxShcompany);console.log("#############");console.log(ifDate);alert(ifDate);
}
二、子事件代码
async function SelectWx(wxShcompany) {let mess="000";let TableName = "csj_wx";let mWhere = " jdName='" + wxShcompany + "'";const postData2 = {BodyValue: `{"Sql_Table": "${TableName}","Sql_KeyField": "Id","Sql_Field": "Id,jdName","JsonField":"Id,jdName","Sql_Where": "${mWhere}","Sql_Sort": "order by Id","ConValue": "sk_1"}`,}; // post请求的数据,可自行定义var sss2 = [{}];const apiUrl2 = import.meta.env.VITE_API_BASE_URL + "/Sql/GridJson";await axios({// async: false, url: apiUrl2,method: "post",data: postData2,}).then((result) => {alert(result.data);if(result.data=="]"){alert("没有数据!");alert(mess);mess="0";}else{alert("有数据!");alert(mess);mess="1";}// console.log("==== 开始读取json数据1 ====");// console.log(result.data);// sss2 = JSON.parse(result.data);// console.log("==== 开始读取json数据2 ====");}).catch((err) => {});alert(mess);
return mess;}