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

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

如何調(diào)用返回值是異步請求函數(shù)的函數(shù)

如何調(diào)用返回值是異步請求函數(shù)的函數(shù)

不負(fù)相思意 2018-11-29 14:10:14
在vue的methods,函數(shù)search作用是返回請求數(shù)據(jù),但是報(bào)錯(cuò)search(options) {  const url = this.isTeacher? '/api/search_Teacher' : '/apis/org/search_student';  const params = options.ids ? { ids: options.ids } : { keyword: this.keyword }; return this.$http.get(url, { params }).then((response) => {   return response.body;  }, (err) =>{   console.log(err);  })},但是不明白如何調(diào)用這個(gè)search,獲取到data??嘗試下面的方法,報(bào)錯(cuò),this.search is not a function??  this.seach({ ids: this.selected }).then((res) => {    if (!res) this.$message.error('搜索失敗');    else this.selectedData = res;  });有沒有好的方法,謝謝
查看完整描述

1 回答

?
www說

TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超8個(gè)贊

async search(options) {

  const url = this.isTeacher? '/api/search_Teacher' : '/apis/org/search_student';

  const params = options.ids ? { ids: options.ids } : { keyword: this.keyword };

  try {

    const res = await this.$http.get(url, { params })

    return res.body

  } catch (e) {

    console.log(e)

  }

},

use

const data = await this.search({ ids: this.selected })

if (!data) this.$message.error('搜索失敗');

else this.selectedData = data;


查看完整回答
反對 回復(fù) 2018-12-30
  • 1 回答
  • 0 關(guān)注
  • 467 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

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