动态

详情 返回 返回

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.