django压缩器的最小化错误



我正在使用一个名为django压缩器的自动缩小工具。然而,django压缩机的缩小似乎会引入错误。

用分号更新的脚本:

之前:

   var app = angular.module('loginApp', [
    "ngRoute",
    "ngAnimate",
    "ngTouch",
    "mobile-angular-ui",
    "ui.router",
    "app.factories.storage",
    "app.controllers.login",
    "angular-loading-bar"

]);

app.config(function ($stateProvider, $urlRouterProvider) {
    // For any unmatched url, send to /route1
    $urlRouterProvider.otherwise("/");
    $stateProvider
        .state('login', {
            url: "/",
            templateUrl: "/static/html/profile/login.html",
            controller: "loginController"
        })
        .state('register', {
            url: "/register",
            templateUrl: "/static/html/profile/register.html",
            controller: "loginController"
        });
});

之后:

var app=angular.module("loginApp",["ngRoute","ngAnimate","ngTouch","mobile-angular-ui","ui.router","app.factories.storage","app.controllers.login","angular-loading-bar"]);app.config(function(e,t){t.otherwise("/");e.state("login",{url:"/",templateUrl:"/static/html/profile/login.html",controller:"loginController"}).state("register",{url:"/register",templateUrl:"/static/html/profile/register.html",controller:"loginController"})})

错误:

Error: $injector:modulerr
Module Error 
Module 'loginApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

错误URL:

https://docs.angularjs.org/error/$injector/modulerr。。。

更新:似乎django压缩器不是问题所在,即使使用在线工具也会出现同样的错误**http://jscompress.com/**

结果是unmify=没有错误,minify=错误

这似乎是产生错误的原因:

app.config(function(e,t){t.otherwise("/");e.state("login",{url:"/",templateUrl:"/static/html/profile/login.html",controller:"loginController"}).state("register",{url:"/register",templateUrl:"/static/html/profile/register.html",controller:"loginController"})})

您缺少两个分号:

app.config(function ($stateProvider, $urlRouterProvider) {
    // For any unmatched url, send to /route1
    $urlRouterProvider.otherwise("/") // <--- HERE
    $stateProvider
        .state('login', {
            url: "/",
            templateUrl: "/static/html/profile/login.html",
            controller: "loginController"
        })
        .state('register', {
            url: "/register",
            templateUrl: "/static/html/profile/register.html",
            controller: "loginController"
        }) // <--- HERE
});

通常,在最小化(尤其是角度代码,它往往非常讨厌被缩小…)之前,总是通过JSHint运行javascript代码是一条很好的经验法则

最新更新