Angularjs 为什么ASP.NET MVC应用程序无限加载脚本?
我刚刚面临一个有趣的问题。那么,我有:Angularjs 为什么ASP.NET MVC应用程序无限加载脚本?,angularjs,asp.net-mvc,bundles,Angularjs,Asp.net Mvc,Bundles,我刚刚面临一个有趣的问题。那么,我有: ASP.NETMVC应用程序 AngularJS应用程序在此应用程序中 嗯,我有一个布局页面: @using System.Web.Optimization <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" />
@using System.Web.Optimization
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>LinkShortener</title>
@Styles.Render("~/bundles/css/")
@Scripts.Render("~/bundles/app/libs/")
@Scripts.Render("~/bundles/app/webapp/")
</head>
<body ng-app="app"></body>
当我在Google Chrome中打开我的页面时,我看到如下内容:
似乎任何脚本都开始加载一些参数,然后一次又一次地加载。。。
这是我第一次看到这个问题。该页被该循环锁定,最后消失
有没有人能猜出魔法是怎么回事
提前感谢。您是否在它们的末尾添加了
@RenderSection(“脚本”,必需:false)
?尝试删除这一行。包括(“~/App/Libraries/Core/angular.js”)您的“~/App/Libraries/Core/angular.js”
和“~/App/Libraries/Core/*.js”
。那些是重复的。因此它将加载angular.js两次。我还猜测“~/App/Resources/*.js”
中有更多角度的脚本“~/App/Resources/*.js”
和“~/App/Resources/*Module.js”
也会拾取重复的内容。@Vitalii,它解决了这个问题。但诀窍是什么?DerekMT12说得对。您只有重复项:)祝您愉快:)末尾的数字是一个缓存破坏值,因此当捆绑包更改时,浏览器总是选择最新版本。
public static void RegisterBundles(BundleCollection bundles)
{
bundles.IgnoreList.Clear();
bundles.Add(new StyleBundle("~/bundles/css/").Include
(
"~/Content/Css/Bootstrap/*.css"
));
bundles.Add(new ScriptBundle("~/bundles/app/libs/")
.Include("~/App/Libraries/jQuery/jquery-1.9.1.js")
.Include("~/App/Libraries/Bootstrap/bootstrap.js")
.Include("~/App/Libraries/Core/angular.js")
.Include("~/App/Libraries/Core/*.js"));
bundles.Add(new ScriptBundle("~/bundles/app/webapp/")
.Include("~/App/App.js")
.Include("~/App/Resources/*Module.js").Include("~/App/Resources/*.js")
.Include("~/App/Controllers/LinkShortenModule.js").Include("~/App/Controllers/*Controller.js"));
}