使用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);
}