1

我刚刚浏览了大量的谷歌页面来解决这个问题,但看起来每个页面都是独一无二的。我的页面源代码显示该包以它应该工作的方式捆绑在一起

 <script src="/Content/js?v=N2f3Y-Z24wBpC67A34qPxjK1CR3eY83Yijs13VtHOwI1"></script>

,但是浏览器(chrome)开发工具表明它无法加载它:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:53608/Content/js/

而且,如果我也单击脚本 src 链接,我还会收到 microsoft 生成的消息,即资源丢失或找不到。

我可以加载其他捆绑包(样式),我想,我在代码布局中遗漏了一些东西,我自己找不到问题。如果你们中的任何人能指出我的错误,我将非常感激,所以这里是代码:

_Layout.cshtml

    @Styles.Render("~/Content/css")
    @Scripts.Render("~/Content/js")
    @Scripts.Render("~/bundles/jquery")

BundleConfig.cs

            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-1.9.1.js",//(tried other numbers as well)
                    "~/Scripts/jquery-ui-1.10.4.js",
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*",
                    "~/Scripts/modernizr-*",
                    "~/Scripts/itpoverlay.js"
                    ));

        bundles.Add(new StyleBundle("~/Content/css").
            Include("~/Content/bootstrap.css",
            //"~/Content/ie.css",
            "~/Content/kwicks-slider.css",
            "~/Content/style.css",
            "~/Content/custom.css",
            "~/Content/responsive.css",
            "~/Content/touchTouch.css"));

        bundles.Add(new ScriptBundle("~/Content/js").Include(
          "~/Content/js/bootstrap.js",
          "~/Content/js/forms.js",
          "~/Content/js/jquery.easing.1.3.js",
          "~/Content/js/jquery.flexslider-min.js",
          "~/Content/js/jquery.kwicks-1.5.1.js",
          "~/Content/js/jquery.preloader.js",
          "~/Content/js/superfish.js",
          "~/Content/js/jquery.js",//(default bundle v1.8.1)
          "~/Content/js/touchTouch.jquery.js"));
       BundleTable.EnableOptimizations = true;

_references.js(我真的不知道它为什么在那里)

/// <reference path="jquery-1.9.1.js" />
/// <reference path="jquery-ui-1.10.4.js" />
/// <reference path="jquery.unobtrusive-ajax.js" />
/// <reference path="jquery.validate.js" />
/// <reference path="jquery.validate.unobtrusive.js" />
/// <reference path="knockout-2.1.0.debug.js" />
/// <reference path="modernizr-2.5.3.js" />

现在对于输出,捆绑包看起来很好生成:

    <link href="/Content/css?v=NASaW-JeM0CkSMQIcoasDpn9k7bKaEK07c7WakA1Y0k1" rel="stylesheet"/>
    <script src="/Content/js?v=N2f3Y-Z24wBpC67A34qPxjK1CR3eY83Yijs13VtHOwI1"></script>
    <script src="/bundles/jquery?v=VwkJeyosUZnIv9pTtkEir1OOQCcR7BXo1RW8kdleacU1"></script>

并且开发工具标记了错误列表(我想,我开始了解 _reference.js 可能用于什么)它是否也应该被捆绑?错误:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:53608/Content/js/
Uncaught TypeError: Object [object Object] has no method 'live' jquery?v=VwkJeyosUZnIv9pTtkEir1OOQCcR7BXo1RW8kdleacU1:1
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:53608/js/jquery.preloader.js

我希望足以发现我的错误,如果有不清楚的地方,我会很乐意用所需的信息更新问题。谢谢,厄尼斯。

4

1 回答 1

0

Jquery live 方法在 1.7 中已弃用,看起来您使用的是 1.9

https://api.jquery.com/live/

所以看起来你有两个选择。找出你在哪里使用 live 方法,并将其更改为使用 .on()。我不能给你具体的代码,因为我不知道你是如何使用 .live()

或查看使用 jquery migrate

http://blog.jquery.com/2013/05/08/jquery-migrate-1-2-1-released/
于 2014-04-08T15:04:25.010 回答