我正在使用 John Papa 的单页应用程序,但在我的开发服务器上遇到了一个问题,它没有下载 require.js。这很奇怪,因为当我在 localhost 中调试时,它可以找到脚本。
HTML
@using System.Web.Optimization
<!DOCTYPE html>
<html>
<head>
<title>CCJS</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
@Styles.Render("~/Content/css")
<script>
// Must be first. IE10 mobile viewport fix
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
var mq = "@@-ms-viewport{width:auto!important}";
msViewportStyle.appendChild(document.createTextNode(mq));
document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
}
</script>
<script src="http://yui.yahooapis.com/3.11.0/build/yui/yui-min.js"></script>
@Scripts.Render("~/scripts/modernizr")
</head>
<body>
<div id="applicationHost">
@RenderPage("_splash.cshtml")
</div>
@Scripts.Render("~/scripts/vendor")
<script src="/App/durandal/amd/require.js" data-main="App/main"></script>
</body>
</html>
我也在使用脚本包。
using System;
using System.Web;
using System.Web.Optimization;
using System.Web.UI;
namespace AgencyUpdate
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
try
{
bundles.IgnoreList.Clear();
AddDefaultIgnorePatterns(bundles.IgnoreList);
bundles.Add(
new ScriptBundle("~/scripts/modernizr")
.Include("~/scripts/modernizr-{version}.js"));
bundles.Add(
new ScriptBundle("~/scripts/vendor")
.Include("~/scripts/jquery-{version}.min.js")
.Include("~/scripts/bootstrap.min.js")
.Include("~/scripts/bootstrap-datepicker.min.js")
.Include("~/scripts/knockout-{version}.js")
.Include("~/scripts/sammy-{version}.min.js")
.Include("~/scripts/moment.min.js")
.Include("~/scripts/Q.min.js")
.Include("~/scripts/breeze.debug.js")
.Include("~/scripts/toastr.min.js")
.Include("~/scripts/apps/exeOnEnter.js")
.Include("~/scripts/custom.js")
.Include("~/scripts/test.js")
.Include("~/scripts/knockout.mapping.js")
.Include("~/scripts/jquery.storage.js")
);
bundles.Add(
new StyleBundle("~/Content/css")
.Include("~/Content/ie10mobile.css")
.Include("~/Content/bootstrap.min.css")
.Include("~/Content/bootstrap-responsive.css")
.Include("~/Content/bootstrap-datepicker.min.css")
.Include("~/Content/font-awesome.min.css")
.Include("~/Content/durandal.css")
.Include("~/Content/toastr.css")
.Include("~/Content/app.css")
.Include("~/Content/styles.css")
.Include("~/Content/custom.css")
);
}
catch (Exception ex)
{
}
}
public static void AddDefaultIgnorePatterns(IgnoreList ignoreList)
{
if (ignoreList == null)
{
throw new ArgumentNullException("ignoreList");
}
ignoreList.Ignore("*.intellisense.js");
ignoreList.Ignore("*-vsdoc.js");
//ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
//ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
//ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
}
}
}
这是我的浏览器