添加对话框的好处:添加对话框可以提升用户体验,减少误操作的风险,并增加用户对操作的信心和掌控感。
添加对话框
this.$confirm('确认删除?')
.then(() => {
//点击了对话框中的确认按钮的逻辑
})
.catch(() => {
//点击了对话框中的取消按钮的逻辑。如果为空,那么不需要执行任何操作
});
案例:
deleteScore(selectIdArray) {
this.$confirm('确认关闭?').then(() => {
this.$axios({
method: "post",
url: "http://localhost:8080/api/score/deleteScore",
data: selectIdArray
}).then((res) => {
if (res.data.code === '200') {
this.$message({
message: res.data.message,
type: "success",
});
this.selectScore();
} else {
this.$message({
message: res.data.message,
type: "failed",
});
}
});
}).catch(() => {});
},