<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] ## async/await 同步 ``` async getBooksAndAuthor(authorId){ const bookPromise = bookModel.fetchAll(); const authorPromise = authorModel.fetch(authorId); const book = await bookPromise; const author = await authorPromise; return { author, books:book.filter(book=>book.authorId === authorId), } } ``` ## async/await 異步 執行 fetch 函數 ``` async function mount() { const result = await Promise.all( fetch('a.json'), fetch('b.json'), fetch('c.json') ); render(...result); } ``` ## then 與 await 比較 ``` function a(code){ return new Promise((resolve, reject)=>{ if (code===1){ resolve({code:1111}) }else{ reject({code:-111}) } }) } function b(code){ return new Promise((resolve, reject)=>{ if (code===1){ resolve({code1:code}) }else{ reject({code1:code}) } }) } function c(code){ return code; } //方式一 let code=1 //成功使用 then。第一個失敗會被catch 接受 b(code).then(res=>{ return a(res.code1) }).then(res=>{ console.log(res); }).catch(err=>{ console.log(err); }) //方式二:使用await // then 越長,使用 await 越方便 async function f(code) { try { let res = await b(code); return await a(res.code1) } catch (e) { console.log(e); return false } } let code2=1 f(code2).then(res=>{ console.log(res); }); ``
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看