第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

所有異步請求完成后的回調(diào)

所有異步請求完成后的回調(diào)

慕運維8079593 2019-03-14 11:15:51
vue的項目中現(xiàn)在有這兩個方法,有個C方法,需要在這兩個異步請求的方法完成后才執(zhí)行,要怎么寫,新手求問,這兩個方法都使用了es6的promise 和 axios這個庫created() {  this._getChannelList()  this._getRecentContact()},method: {    _getChannelList() {      getChannelList(this.getCookie('sender'), this.getCookie('version')).then(res => {        // 成功      }).catch(err => {        console.log(err)      })    },    _getRecentContact() {      getRecentContact(this.getCookie('sender')).then(res => {        // 成功      }).catch(err => {        console.log(err)      })    },    c() {       // 需要在上面兩個方法都請求完畢才執(zhí)行    }}
查看完整描述

3 回答

?
縹緲止盈

TA貢獻2041條經(jīng)驗 獲得超4個贊

axios可以執(zhí)行多個并發(fā)請求


function getUserAccount() {

  return axios.get('/user/12345');

}


function getUserPermissions() {

  return axios.get('/user/12345/permissions');

}


axios.all([getUserAccount(), getUserPermissions()])

  .then(axios.spread(function (acct, perms) {

    // 兩個請求現(xiàn)在都執(zhí)行完成

  }));


查看完整回答
反對 回復 2019-03-18
?
拉風的咖菲貓

TA貢獻1995條經(jīng)驗 獲得超2個贊

可以用 Promise.all 來控制流程


查看完整回答
反對 回復 2019-03-18
  • 3 回答
  • 0 關(guān)注
  • 898 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號