我试图在我的SweetAlerts核心项目中使用.Net,但它的行为不正常。从他们的文档来看,你似乎不需要定义模型,也不需要它弹出的地方。然而,当我使用它,它永远不会弹出一个模式,但将显示在我的屏幕左下角的一切。

我试着把它一直移动到我的应用程序的布局上,看看这些层是否导致了问题,但是不管我把代码放在哪里,它总是在左下角结束。
下面是我的代码片段。
@RenderBody()
<button id="testbutton">TEST</button>
<script src="~/lib/sweetalert/dist/sweetalert.min.js"></script>
<script>
var SweetAlert = function () { };
//examples
SweetAlert.prototype.init = function () {
//Parameter
$('#testbutton').on('click', function (e) {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#f0c541",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
}, function (isConfirm) {
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
return false;
});
}
$.SweetAlert = new SweetAlert, $.SweetAlert.Constructor = SweetAlert;
$.SweetAlert.init();
</script>发布于 2020-01-30 14:39:29
似乎您还没有加载css文件的出汗警报,或者如果这不是问题,检查您自己的css样式,并了解冲突的原因。
https://stackoverflow.com/questions/59988371
复制相似问题