报错:Unexpected reserved word ‘await‘

报错:Unexpected reserved word ‘await’

async remove(param, index) {
      this.$confirm(`是否继续删除${param.name}`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      })
        .then(() => {
          await commonApi.removeCategory(param)
          this.list()
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },

修改为:

remove(param, index) {
      this.$confirm(`是否继续删除${param.name}`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        center: true
      })
        .then(async () => {
          await commonApi.removeCategory(param)
          this.list()
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },

你可能感兴趣的:(js,css,前端)