vue with async, await synchronization request

 

The following is a vue method of demo:

 

loadTableData : async function() {
              
                var reses = await $.ajax({
                    type:'post',
                    url:'/linewell/system/user/queryPageList.do'/*,
                });

                console.log("reses", reses);
            }

 

 

Which method requires modification with async, then

Variables var = the await request 

can be in response to a request reses assigned to, or in accordance with a conventional asynchronous request, reses defined variables, the success of reses assignment function, printed reses still empty.

But we generally do not recommend so to write, if indeed you need to get the appropriate information, you can encapsulate the business code inside a method, then the success callback function, calling this method, passing in the required parameters.

Guess you like

Origin www.cnblogs.com/chenmz1995/p/11747168.html