如何使 AngularJS 路由像 index.html#/myPage 一样与 index.html/#/myPage 一起工作
How to make AngularJS route works with index.html/#/myPage like index.html#/myPage
我当前的 iFrame 页面加载了 index.html#/myPage 它在 Chrome 或 Safari 下运行良好,但不适用于 IE 11
我在 SO 上找到了 this solution:
在 # (index.html/#/myPage) 前加一个 / 就可以解决你的问题
它看起来很简单,但在我的例子中它会产生 404 页面未找到
我的路由提供商似乎不支持# 之前的 /,为什么?
路由代码:
appSkeleton.config(
function ($routeProvider) {
$routeProvider.
when('/', {
template: '<skeleton-manage></skeleton-manage>'
})
.when('/skeletonManage', {
template: '<skeleton-display-and-manage></skeleton-display-and-manage>'
})
.when('/employeeManage/:employeeId/:displayMode/:idItemClick?', {
template: '<employee-display-and-manage></employee-display-and-manage>'
})
.otherwise({
redirectTo:'/'
});
}
);
该应用程序在 Node.JS 服务器上运行
它不适用于 app/index.html#/ 但它适用于 app/#/,您不需要在 [=17 上指定 index.html =]
或者您可以通过代码
直接重定向到 URL 而无需 index.html
var url = window.location.href;
if(url.indexOf("index.html") > 0){
window.location.replace(url.replace("index.html",""));
}
我当前的 iFrame 页面加载了 index.html#/myPage 它在 Chrome 或 Safari 下运行良好,但不适用于 IE 11
我在 SO 上找到了 this solution: 在 # (index.html/#/myPage) 前加一个 / 就可以解决你的问题
它看起来很简单,但在我的例子中它会产生 404 页面未找到
我的路由提供商似乎不支持# 之前的 /,为什么?
路由代码:
appSkeleton.config(
function ($routeProvider) {
$routeProvider.
when('/', {
template: '<skeleton-manage></skeleton-manage>'
})
.when('/skeletonManage', {
template: '<skeleton-display-and-manage></skeleton-display-and-manage>'
})
.when('/employeeManage/:employeeId/:displayMode/:idItemClick?', {
template: '<employee-display-and-manage></employee-display-and-manage>'
})
.otherwise({
redirectTo:'/'
});
}
);
该应用程序在 Node.JS 服务器上运行
它不适用于 app/index.html#/ 但它适用于 app/#/,您不需要在 [=17 上指定 index.html =] 或者您可以通过代码
直接重定向到 URL 而无需 index.htmlvar url = window.location.href;
if(url.indexOf("index.html") > 0){
window.location.replace(url.replace("index.html",""));
}