Unexpected reserved word 'await' (95:4)
时间: 2024-01-27 18:06:01 浏览: 130
错误提示“Unexpected reserved word 'await'”是因为在代码中使用了不被支持的await关键字。根据引用的内容,这是因为在async函数handleDelete()的定义上错误地使用了async关键字,应该将async关键字放在匿名函数的位置。正确的做法是将async关键字放在.then()方法的前面,并将匿名函数定义为async函数。修改后的代码如下:
```
handleDelete() {
let folderFilesIds = [1, 2]
this.$confirm('此操作将永久删除文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
await this.confirmHandleFiles(folderFilesIds)
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
}
```
此外,根据引用的内容,小程序本身不支持async/await语法。如果想在小程序中使用async/await,可以借助第三方库如regenerator来实现。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [Unexpected reserved word ‘await](https://blog.csdn.net/m0_37714008/article/details/119349924)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [小程序如何支持使用 async/await详解](https://download.csdn.net/download/weixin_38747444/13631381)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]