net::ERR_EMPTY_RESPONSE 当尝试在 AngularJS 指令中查找 CSS 文件时

net::ERR_EMPTY_RESPONSE when trying to find css file in angularjs directive

本文关键字:指令 查找 文件 AngularJS CSS EMPTY ERR RESPONSE net      更新时间:2023-09-26

当我的网页尝试从指令访问我的 css 文件时,我收到net::ERR_EMPTY_RESPONSE

我正在使用 door3 的按需 css,它允许您仅在需要时延迟加载 css 文件。 这在我的路由文件中完美运行,但在我的指令文件中,它会在 Chrome 中获取net::ERR_EMPTY_RESPONSE。以下是 door3 的文档: http://door3.com/insights/introducing-angularcss-css-demand-angularjs#.VtPeDygrKM8

在研究此错误时,我遇到了有人建议它可能是我的广告拦截器,所以我关闭了它,没有任何变化。 我在StackOveflow或谷歌上找不到与我的问题类似的其他内容。 我加倍,三倍检查了css文件的名称和路径,一切看起来都不错。 可能是什么原因造成的?

这是我的应用程序.js文件,它从 door3 按需配置 css:

angular.module('task2', ['ngRoute', 'ngResource', 'door3.css'])
.config(function($cssProvider) { 
        angular.extend($cssProvider.defaults, { 
            persist: true, 
            preload: true, 
            bustCache: true 
        }); 
});

这是我收到错误的指令,第 1 节.js:

angular.module('task2')
.directive('section1', function() {
    return {
        restrict: 'E',
        templateUrl: 'partials/home/section1.html',
        controller: function() {
            this.getLogo = function() {
                return logoImage;
            };
            this.brandName = "Geek Label";
            this.section1Desc = "A team of self confessed geeks who are all about great digital design";
       },
       controllerAs: 'section1Ctrl',
       css: 'css/partials/home/section1.css'
    };
});
var logoImage = {
    name: 'eyeglasses logo',
    url: 'content/images/eyeglassesLogo.png'
};

以下是关联的 css 文件,第 1 节.css:

#section1Row {
    width: 100%;
}
#section1 {
    height: 100vh;/*100% of viewport height*/
    background-color: #D9435E;
    position: relative;
}

这是路由文件,其中包含一个关联的 css 文件,该文件工作正常,路由.js:

//Routes
angular.module('task2')
.config(function($routeProvider) {
     $routeProvider.
     when('/home', {
         templateUrl: 'partials/home/home.html',
         name: "Home",
         controller: 'HomeController',
         controllerAs: "homeCtrl",
         css: 'css/partials/home/home.css'
     }).
     otherwise({
       redirectTo: '/home'
     });
});

我在 Chrome 中收到以下错误: GET http://localhost:8383/CompucorpTask2/n?cache=1456723626330 net::ERR_EMPTY_RESPONSE

Css文件没有被提供..这就是错误的意思。尝试检查它们是否位于服务器端的正确文件夹中。