Javascript toastr 未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29475624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 03:25:19  来源:igfitidea点击:

toastr is not defined

javascriptjqueryhtmltoastr

提问by ontheroadmike

Receiving the following error in developer console when loading the page:

加载页面时在开发者控制台中收到以下错误:

Uncaught ReferenceError: toastr is not defined

未捕获的 ReferenceError:toastr 未定义

Here are the html contents. Can someone please explain to me why toastr is undefined?

这里是 html 内容。有人可以向我解释为什么 toastr 未定义吗?

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css">
</head>

<body>
  <p>Toastr TEST</p>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js">
  </script>
  <script scr="http://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.0.2/js/toastr.min.js">
  </script>
  <script>
    $(document).ready(function() {
      console.log("document.ready");
      toastr.info('document.ready');
    });

    $(window).load(function() {
      console.log("window.load");
      toastr.info('window.load');
    });
  </script>
</body>

</html>

回答by DrCord

You have the script elemen's src attribute wrongly spelled for the toaster.js file, it should be "src" but is "scr".

您为 toaster.js 文件错误地拼写了脚本元素的 src 属性,它应该是“src”,但它是“scr”。