在使用element-ui的this.$confirm时,点击取消Cancel按钮或者关闭按钮时,控制台报错,但程序正常运行。
控制台报错如下:
报错时的代码:
this.$confirm("您确定删除选中的记录信息吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.$http(qarAuthTemplateDelete(list), (res) => {
if (res.code == 0) {
this.$toaster.success("删除成功");
this.Inquire();
}
});
})
原因时写法错误,没有写catch导致的,所以解决方案是加上catch:
this.$confirm("您确定删除选中的记录信息吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.$http(qarAuthTemplateDelete(list), (res) => {
if (res.code == 0) {
this.$toaster.success("删除成功");
this.Inquire();
}
});
})
.catch(() => {});