動態

詳情 返回 返回

async await實際用法 - 動態 詳情

async handleSubmit() {
      await this.handleSubmitReport()  // 1
      await this.handleSubmitEdit()    // 2
      this.showSuccess = true          // 3
      this.showSuccessText = '你已成功提交檢查結果!'
    },

// 執行接口1
async handleSubmitReport() {

  const { data } = await postAction(this.api.report, this.params.hiddenList)
  if (data.success) {
    return data.result
  } else {
    this.$message.error(data.message)
    this.$tip.loaded()
    return null
  }
},

// 執行接口2
async handleSubmitEdit() {
  const { data } = await postAction(this.api.edit, this.dataInfo)
  if (data.success) {
    return data.result
  } else {
    this.$message.error(data.message)
    this.$tip.loaded()
    return null
  }
},
user avatar simonbaker_5ec61c266b1df 頭像 sean_5efd514dcd979 頭像 ssbunny 頭像 mstech 頭像 webinfoq 頭像 chenqiwen 頭像 mochou_5b3c64f18b5f1 頭像
點贊 7 用戶, 點贊了這篇動態!
點贊

Add a new 評論

Some HTML is okay.