更新时间:2023-12-05 17:37:40
这可能有很多问题:本质上是 routeProvider 找不到文件并递归加载默认文件的问题.
This could be a number of issues: essentially it's a problem of routeProvider not finding a file and recursively loading the default.
对我来说,结果不是缩小,而是 js 的串联导致了问题.
For me, it turned out that it wasn't minification but concatenation of the js that caused the problems.
angular.module('myApp').config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/listing.html',
controller: 'ListingCtrl'
})
.otherwise({
redirectTo: '/'
});
}]).constant('FIREBASE_URL', 'something');
您会注意到,如果应用程序找不到文件(即 otherwise
),它将重定向到根目录,在这种情况下会加载 templateUrl代码>.但是如果您的
templateUrl
是错误的,那么它会导致递归重新加载 index.html
加载 angular(以及其他所有内容)一遍又一遍.
You'll notice that if the app can't find a file (i.e., otherwise
), then it will redirect to the root, which in this case loads the templateUrl
. But if your templateUrl
is wrong, then it will cause a recursion that reloads index.html
loading angular (and everything else) over and over.
就我而言,grunt-concat 导致 templateUrl 在构建之后出错,但之前没有.
In my case, grunt-concat caused the templateUrl to be wrong after build, but not before.