嗨,我正在尝试将Alertify.js作为警报弹出窗口包含在我的网页上,但是我不确定为什么不显示它。尽管不确定我是否使用正确,我已经下载了库和源代码来进行警报。任何建议都会有很大帮助。提前致谢!

   <head>
<meta charset="utf-8">

<link rel="stylesheet"
href="C:/Users/Documents/alertifyjs/css/alertify.min.css" />
<link rel="stylesheet" href="C:/Users/Documents/alertifyjs/css/alertify.css"
id="toggleCSS" />
<meta name="viewport" content="width=device-width">
<style>
    .alertify-log-custom {
        background: blue;
    }
</style>
</head>
<body>

<h2>Dialogs</h2>
<a href="#" id="alert">Alert Dialog</a><br>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script src="C:/Users/Documents/AlertifyJS-master/AlertifyJS-
master/build/alertify.min.js"></script>

<script>
    function reset () {
        $("#toggleCSS").attr("href", "alertify.default.css");
        alertify.set({
            labels : {
                ok     : "OK",
                cancel : "Cancel"
            },
            delay : 5000,
            buttonReverse : false,
            buttonFocus   : "ok"
        });
    }

    $("#alert").on( 'click', function () {
        reset();
        alertify.alert("This is an alert dialog");
        return false;
    });
   </script>

   </body>
   </html>


更新

下面是控制台上显示的错误。

Uncaught TypeError: Cannot read property 'dialog' of undefined
at b (alertify.min.js:2)
at Object.setting (alertify.min.js:2)
at Object.set (alertify.min.js:2)
at reset (alertify.html:44)
at HTMLAnchorElement.<anonymous> (alertify.html:56)
at HTMLAnchorElement.dispatch (jquery-1.9.1.js:3074)
at HTMLAnchorElement.elemData.handle (jquery-1.9.1.js:2750)
alertify.default.css:1 Failed to load resource: net::ERR_FILE_NOT_FOUND

最佳答案

试试这个代替改变这个

alertify.set({


为了这

alertify.confirm().set({


它发生在我身上,取决于Alertify版本

关于javascript - 下载库和源代码后在本地使用Alertify.js,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50466503/

10-13 00:54