使用confirm时,报如下错误:
Uncaught (in promise) cancel
效果如下:

原因:因为confirm省略了.catch(),从而无法捕获confirm取消的操作。这里.catch()不能省略。
解决:添加.catch(),把错误return 出去就行
async removeUserById(id) {
const confirmResult = await this.$confirm('此操作将永久删除该用户, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).catch(err=>err) // .catch()不能省略
console.log(confirmResult);
}
本文介绍了在使用confirm对话框时遇到的取消操作未被捕获的问题及其解决方案。通过添加.catch()来处理取消操作,确保程序的健壮性。

2万+

被折叠的 条评论
为什么被折叠?



