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
  }
},

你可能感兴趣的:(async await实际用法)