this.$confirm('此操作將永久刪除該文件, 是否繼續?', '提示', {
confirmButtonText: '確定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
//業務邏輯代碼
this.$message({
type: 'success',
message: '刪除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消刪除'
});
});
有一次代碼一直走catch的,提示已取消,然后在then里面添加console.log(“then”)代碼,發現其實是有走then里面代碼的,但是then里面的代碼有錯誤,所以才跑的catch ,要將代碼錯誤報錯出來,將業務邏輯代碼復制出來跑一下就可以,或者,catch的err輸出一下就行
總結:代碼看起來沒問題,然后一直走catch,代表then里面的代碼有問題
