javascript - 在 gulp 服务器中刷新 AngularJS 页面后,显示错误无法 GET
问题描述
我有一个带有 AngularJS 1.6 应用程序的 gulp 服务器。
我有一个 ng 路由器。我正在尝试#!
从 url 中删除符号,所以我使用了 ng-router。我用过$locationProvider.html5Mode(true);
,并且在 index.html 中我用过<base href="/">
。
但是当我刷新页面时它显示无法获取/ui/index.html/
我正在使用gulp
服务器。
应用程序.js
var app = angular.module("apollo", ['ngRoute']);
app.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/ui/index.html/', {
templateUrl: 'root.html',
controller: 'HeaderCtrl'
})
.when('/ui/:appName/', {
templateUrl: 'apps/' + localStorage.getItem('locationApp') + "/controllers/home/templates/home.template.html"
})
.otherwise({
redirectTo: '/ui/index.html/'
});
$locationProvider.html5Mode(true);
});
索引.html
<!DOCTYPE html>
<html>
<head>
<title>Apollo</title>
<base href="/">
<script src="library/angular.min.js"></script>
<script src="library/angular-route.js"></script>
<script src="app.js"></script>
<script src="services/apollo-headerCtrl.js"></script>
<script src="services/AppCtrl.js"></script>
</head>
<body ng-app="apollo">
<div ng-view></div>
</body>
</html>
解决方案
推荐阅读
- java - itext 7中带有childrenElements的段落断字
- openedge - 使用追加时如何在页面结果末尾添加空格?
- java - JAX-RS WebClient 在重定向时忽略 Kerberos 身份验证
- azure-application-insights - 具有超过 1 个相关调用的应用程序分析报告请求
- asp.net - 请求外部密码保护的 XML 信息并解析到我的经典 ASP 页面
- c++ - 将具有 2000 个值的字符串与具有 1 个值的字符串进行比较
- linux - 从用户空间启用/读取 PMU
- spring-boot - 针对 xsd 的骆驼验证:找不到元素“地址”的声明
- image - 如何在处理中从单个图像制作动画?
- sql - 在自定义聚合函数中查找 SUM 和 MAX