我当前的 iFrame 页面加载了 index.html#/myPage 它在 Chrome 或 Safari 下运行良好,但不适用于 IE 11
我找到了 this solution所以: 在 # (index.html/#/myPage) 前添加一个/即可解决您的问题
它看起来很简单,但在我的例子中它产生了一个404 Page not found
我的路由提供者似乎不支持#之前的/,为什么?
路由代码:
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/#/,您不需要在 URL 上指定 index.html 或者您可以通过代码直接重定向到没有 index.html 的 URL
var url = window.location.href;
if(url.indexOf("index.html") > 0){
window.location.replace(url.replace("index.html",""));
}
关于javascript - 如何使 AngularJS 路由像 index.html#/myPage 一样与 index.html/#/myPage 一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28407576/