首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在使用Angular.js和.htaccess重新加载页面时不获取JS/CSS文件链接

在使用Angular.js和.htaccess重新加载页面时不获取JS/CSS文件链接
EN

Stack Overflow用户
提问于 2015-10-11 10:15:48
回答 1查看 121关注 0票数 0

在使用Angular.js和.htaccess重新加载页面时,我得到了一些链接错误。实际上,我试图删除angular.js中的哈希标签。我设置了.htaccess文件并设置了基href。我在下面解释我的代码。

.htaccess:

代码语言:javascript
运行
复制
<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /Gofasto/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !.*\.(css|js|html|png|jpg|jpeg|gif|txt)
    RewriteRule (.*) index.html [L]
</IfModule>

loginRoute.js:

代码语言:javascript
运行
复制
var Admin=angular.module('Channabasavashwara',['ui.router']);
Admin.config(function($stateProvider, $urlRouterProvider,$locationProvider) {
    $urlRouterProvider.otherwise('/');
    $stateProvider
     .state('/', {
            url: '/',
            templateUrl: 'dashboardview/login.html',
            controller: 'loginController'
        })
        .state('dashboard', {
            url: '/dashboard',
            templateUrl: 'dashboardview/dashboard.html',
            controller: 'dashboardController'
        })
        .state('dashboard.profile', {
        url: '/profile',
        templateUrl: 'dashboardview/profile.html',
        controller: 'profileController'
    })
    .state('dashboard.dept', {
        url: '/dept',
        templateUrl: 'dashboardview/dept.html',
        controller: 'deptController'
    })
    .state('dashboard.princpal', {
        url: '/princpal',
        templateUrl: 'dashboardview/princpal.html',
        controller: 'princpalController'
    })
    .state('dashboard.dept_head', {
        url: '/dept_head',
        templateUrl: 'dashboardview/depthead.html',
        controller: 'deptheadController'
    })
    $locationProvider.html5Mode({
      enabled: true,
      requireBase: true
    });

})

当我在仪表板页面,它的工作fine.but,当我在配置文件页,第一次,它的工作良好,当我重新加载这个页面时,我得到以下错误。

代码语言:javascript
运行
复制
failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/controller/profileController.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/controller/deptController.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/controller/deptheadController.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/js/newbill.js Failed to load resource: the server responded with a status of 404 (Not Found)
profile:118 Uncaught TypeError: $(...).chosen is not a function
http://localhost/Gofasto/dashboard/css/bootstrap.min.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/css/style22.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/css/plugins.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/css/pace.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/css/style.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost/Gofasto/dashboard/icons/font-awesome/css/font-awesome.min.css Failed to load resource: the server responded with a status of 404 (Not Found)

我所有的css和js文件夹都在Gofasto文件夹中,但是它显示错了第一次出现的链接,我还在索引page.Please中设置了<base href="/Gofasto/">来帮助我解决这个错误。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-11 13:26:45

在引用资源时尝试使用绝对路径,例如:

代码语言:javascript
运行
复制
<link rel="stylesheet" type="text/css" href="/Gofasto/css/style.css">

..。或者:

代码语言:javascript
运行
复制
<link rel="stylesheet" type="text/css" href="/css/style.css">

..。而不是:

代码语言:javascript
运行
复制
<link rel="stylesheet" type="text/css" href="css/style.css">
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33063851

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档