未捕获的ReferenceError:noty未定义

时间:2017-12-19 07:29:30

标签: javascript jquery asp.net notifications noty

我遇到了一个问题,即使用noty插件无法显示通知。 我在ASP.net Web应用程序中包含了这个插件。

_Layout.cshtml

<link href="~/lib/bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
<link href="~/lib/bootstrap-table/dist/bootstrap-table.css" rel="stylesheet" /> 
<link href="~/css/site.css" rel="stylesheet" />
<link rel="stylesheet" href="~/css/sticky_footer.css" />
<link href="~/lib/noty/lib/noty.css" rel="stylesheet" />

<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
<script src="~/lib/jquery-validation/dist/additional-methods.js"></script>
<script src="~/lib/js-cookie/src/js.cookie.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/lib/bootstrap-table/dist/bootstrap-table.js"></script>
<script src="~/lib/noty/lib/noty.js"></script>
<script src="~/lib/moment/min/moment.min.js"></script>
<script src="~/lib/he/he.js"></script>
<script src="~/lib/bootstrap-table-contextmenu/dist/bootstrap-table-contextmenu.min.js"></script>

Create.cshtml

 $updateSessionSynopsisHandler.done(function (data, textStatus, jqXHR) {
            noty({
                text: data.message, type: 'success',
                layout: 'center'
            });

        });

错误 enter image description here

1 个答案:

答案 0 :(得分:2)

正如在Noty document中所写,我认为Noty是一个构造函数。它应该在您想要使用之前进行实例化。试试这个

$updateSessionSynopsisHandler.done(function (data, textStatus, jqXHR) {
        new Noty({
            text: data.message, type: 'success',
            layout: 'center'
        }).show();
    });