element 报错:Unexpected reserved word 'await'

 

 

async handleDelete() {
  let folderFilesIds = [1, 2]
  this.$confirm('此操作将永久删除文件, 是否继续?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    await this.confirmHandleFiles(folderFilesIds)
  }).catch(() => {
    this.$message({
      type: 'info',
      message: '已取消删除'
    });
  });
},

之前报错Unexpected reserved word ‘await’,是因为错把async放到handleDelete上,这里async和await是成对出现的,所以应该放在匿名函数的位置,加async的函数会被await阻塞,await会跳出async让出线程,所以说学一个东西是一回事,会用一个东西是另外一回事

 

转: https://blog.csdn.net/weixin_49651654/article/details/122139353

 

posted @ 2022-06-05 13:50  与f  阅读(917)  评论(0编辑  收藏  举报