我不知道删除行的位置和方式:
Clanovi.remove(this._id);
在甜蜜警报中,我试着这样:
'click .btn-danger'()
{
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm) {
Clanovi.remove(this._id);
swal("Deleted!", "Your imaginary file has been deleted.", "success");
}
else
{
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
}
这不起作用,我不知道如何做到这一点。它不会删除。
答案 0 :(得分:0)
可能性this
不是您所期望的。尝试:
'click .btn-danger'()
{
let that = this;
console.log(that._id);
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm) {
Clanovi.remove(that._id);
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
}
或 - 您尚未设置允许/拒绝规则以允许在客户端删除。
从安全pov开始,你最好调用一种方法来删除而不是在客户端上进行删除。
答案 1 :(得分:0)
以下是对我有用的示例:
const answer = await swal({
title: 'Are you sure?',
text: 'You will not be able to recover this imaginary file!',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#dd6b55',
cancelButtonColor: '#d44',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, keet it',
closeOnConfirm: false
})
如果用户确认,答案将为{value: true}