gpt4 book ai didi

javascript - 使用 Angularjs 和 .htaccess 重新加载页面时未获取 JS/CSS 文件链接

转载 作者:行者123 更新时间:2023-12-03 08:40:04 25 4
gpt4 key购买 nike

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

.htaccess:

<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:

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
});

})

当我在仪表板页面时,它工作正常。但是当我第一次在个人资料页面时,它工作正常,当我再次重新加载此页面时,我收到以下错误。

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 内文件夹,但它第一次显示正确的链接时显示错误的链接。我还设置了 <base href="/Gofasto/">在索引页中。请帮助我解决此错误。

最佳答案

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

<link rel="stylesheet" type="text/css" href="/Gofasto/css/style.css">

...或:

<link rel="stylesheet" type="text/css" href="/css/style.css">

...而不是:

<link rel="stylesheet" type="text/css" href="css/style.css">

关于javascript - 使用 Angularjs 和 .htaccess 重新加载页面时未获取 JS/CSS 文件链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33063851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com