问题描述
handleDelete(){
// 1.弹出提示框
this.$confirm("此操作永久删除当前数据,是否继续?","提示",{
confirmButtonText: '确定',
cancelButtonText: '取消',
type:"info"
}).then(()=> {
// 2.做删除业务
axios.delete("/books/"+row.id).then((res)=> {
if(res.data.code == 20021) {
this.$message.success("删除成功");
} else {
this.$message.error("删除失败");
}
})
}).finally(()=> {
this.getAll();
}).catch(()=> {
// 3.取消删除
this.$message.info("取消删除操作");
})
}
问题原因:
由于then中的代码运行报错,catch捕捉到错误,所以一直运行catch中的代码。
以上代码由于函数没有接受参数,却使用了参数row而报错。
解决方法:
在catch中第一行console输出一下,看是否是由于then中代码错误,而一直运行catch中的代码。