1

我有一个 core.js 文件,其中包含所有关键的 JS 库和脚本,例如添加到我的 HTML 页面标题中的 jQuery。在页脚中,我有所有非关键的 jQuery 插件和脚本,但是我不断从其中一些插件中收到“jQuery undefined”错误,即使它们被包装在 jQuery(document).ready(function(){ 中。 .. }. 当我从 core.js 文件中删除 jQuery 并在标题中单独链接到它时,没有错误。

    <head>
      <script src="core.js"></script>
    </head>

    <body>

     ....
     ....
       <script src="plugins.js"></script>
    </body>

Core.js (pasetbin)

是什么赋予了?

4

1 回答 1

0

Well, just looking at the code, you're not ending the jQuery.extend() call properly (line 262), so any plugins after that will not be loaded due to a parse error (ASI doesn't help since the following is all parseable).

Why then the jQuery symbol is not exported to other javascript files is a different matter, but since you say loading it in a separate file helps, this is likely part of the problem.

于 2012-07-03T15:10:17.137 回答