当用户点击删除按钮时,我试图制作一个sweetalert,它会触发sweetalert,当用户点击IDisposable
时,它应该发出一个axois请求来删除状态。当用户点击Yes, Delete it!
时,sweetalert关闭但请求永远不会发出。如果我删除sweetalert并保留请求,它将删除记录。
删除按钮
Yes, Delete it!
删除方法
<button @click="destroy(statuses.id)" class="btn btn-danger btn-flat btn-sm"> <i class="fa fa-remove"></i> </button>
答案 0 :(得分:2)
根据文档,您可以执行此操作。
swal({
title: "Delete this order status?",
text: "Are you sure? You won't be able to revert this!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes, Delete it!"
}).then((result) => { // <--
if (result.value) { // <-- if confirmed
del('status-delete/' + id);
}
});
答案 1 :(得分:2)
试试这个:
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, cancel!',
buttonsStyling: true
}).then(function (isConfirm) {
if(isConfirm.value === true) {
axios.post('status-delete/'+id, {
data: {
id: id
}
}).then(function (response) {
console.log('success')
})
}
});