asnyc

  1. 構造
    非同期関数名([PARAM [、PARAM [、... PARAM]]]){文}
    

      

  2. awaitキーワードは、非同期機能でのみ有効です。
    プロミスオブジェクトを待つのawait演算子、それだけで非同期関数の非同期関数内で使用することができます。
    機能testAwait(){ 
       新しい約束返す((解決)=> { 
           たsetTimeout(関数(){ 
              にconsole.log( "testAwaitを"); 
              解決(); 
           }、1000); 
       }); 
    } 
     
    非同期関数helloAsync(){ 
       のawait testAwait()。
       console.log( "helloAsync"); 
     } 
    helloAsync()。
    // testAwait 
    // helloAsync
    

      

おすすめ

転載: www.cnblogs.com/anbozhu7/p/11820950.html