SweetAlert 未在模态中显示

SweetAlert not showing in Modal

我正在尝试在我的 .Net Core 项目中使用 SweetAlerts,但它运行不正常。从查看他们的文档来看,您似乎根本不需要定义模式或它弹出的位置。但是,当我使用它时,它永远不会以模式弹出,而是会显示在屏幕左下角的所有内容下方。

我尝试将它一直移动到我的应用程序的布局以查看层是否导致问题,但无论我将代码放在哪里,它总是在左下角结束。

这是我的代码片段。

@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>

看来你没有加载汗水警报的css文件,如果不是问题,请检查你自己的css样式并查看冲突原因。