首页 新闻 会员 周边

vue 警示框执行不了

0
悬赏园豆:5 [已解决问题] 解决于 2022-08-11 21:14

delData() {
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
debugger;
console.log(vm_data.form.Sid);
var ss = "33";
var d = {
id: vm_data.form.Sid
};
var jsondata = JSON.stringify(d);
$.ajax({
url: "/QPAE/Delete",
type: "post",
data: jsondata,
contentType: "application/json",
dataType: "json",
success: function (e) {
if (e.flag) {
this.$message({
type: 'success',
message: '删除成功!'});
window.location.href = "@Url.Action("Index")";
}
}
});
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
}

红色标注的代码加上去后,就不执行了, 统统都是 已取消删除,不知道是那里错了,哎

郑英灿的主页 郑英灿 | 初学一级 | 园豆:156
提问于:2022-08-11 15:48
< >
分享
最佳答案
0

在外面 const _this = this,然后在里面是有 _this.$message...

收获园豆:5
人间春风意 | 老鸟四级 |园豆:2370 | 2022-08-11 18:42

是要把 _this.$message... 改成 $message... 吗

郑英灿 | 园豆:156 (初学一级) | 2022-08-11 19:22

vm.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
var d = {
ids: vm._data.form.Sid
};
var jsondata = JSON.stringify(d);
$.ajax({
url: "/QPAE/Delete",
type: "post",
data: jsondata,
contentType: "application/json",
dataType: "json",
success: function (e) {
if (e.flag) {
vm.$message({
type: 'success',
message: '删除成功!'
});
window.location.href = "@Url.Action("Index")";
}
}
});

            }).catch(() => {
                vm.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });

this改成vm就可以了

郑英灿 | 园豆:156 (初学一级) | 2022-08-11 21:13
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册