2016-12-14 56 views
0

我想在我的mvc应用程序中使用toastr。当我从下载的NuGet我发现这两个文件 添加到我的脚本文件夹无法获取toast在我的mvc应用程序中工作

toastr.js 
    toastr.min.js 

我加了js文件给我的布局页

<script src="~/Scripts/jquery-1.12.4.min.js"></script> 
    <script src="~/Scripts/toastr.js"></script> 

我现在写了下面的代码在我的页面布局在脚本部分。 当我运行我的应用程序时,没有任何反应。我错过了什么吗?

 $(document).ready(function() { 

      displayToastr(); 

     }); 

     function displayToastr() { 
      //alert('yes'); 
      // Display a info toast, with no title 
      toastr.info('Hi Mahedee, This information for you.'); 

      // Display a warning toast, with no title 
      toastr.warning('Hi Mahedee, This the first warning for you!'); 

      // Display a success toast, with a title 
      toastr.success('Yes! You have successfully completed your task!', 'Congratulation for you, Mahedee!'); 

      // Display an error toast, with a title 
      toastr.error('An error occured in the solution!', 'Please contact with system administrator.'); 
     } 
+0

这是我的解决方案。我错过了css文件,当我添加它时,一切都开始奏效。 – user2320476

回答

0

这应该有效。你确定你的JS路径是否正常,并且在加载这些js库之后运行你的代码?

+0

是的,我做到了。它不工作。我想这应该是一件容易的事情。我的布局页面开始时有链接。他们需要结束吗? – user2320476

+0

请为此创建一个小提琴或提供有效的代码示例 - 完整的HTML。我使用CDN来源在当地做了一个快速的工作,它工作... – marcinrek

相关问题