Nik*_*kov 7 javascript angularjs angular-ui-router
我正在使用ui-router,并且profile状态如下:
.state('profile', {
url: "/profile",
templateUrl: "views/profile.html",
controller: 'ProfileCtrl',
resolve: {
currentUser: function(gamAuth){
return gamAuth.checkCurrentUser(config.userRol.user)
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试重新加载/刷新页面时,我收到以下消息:
Cannot GET /profile
Run Code Online (Sandbox Code Playgroud)
当我在以下位置重新加载"目标网页"时http://localhost:9000/,不会出现此问题,其状态如下$stateProvider:
.state('home', {
url: "/",
[...]
})
Run Code Online (Sandbox Code Playgroud)
我在用: $locationProvider.html5Mode(true);
我尝试在这里提供决策树中建议的绝对URL
我也尝试过在线发现的一些建议,最受欢迎的是这些内容(将其放在本app.run()节中):
$state.transitionTo($state.current, $stateParams, {
reload: true,
inherit: false,
notify: true
});
Run Code Online (Sandbox Code Playgroud)
所有方法都经过测试,无论<base href="/">标签是否存在于<head>我的标签中index.html.感谢您的时间.
如果您想使用不带“#”前缀的 url,则需要将html5mode启用为 true。
您还需要按照此处所述添加 modRewrtie
先决条件:
npm install --save-dev connect-modrewrite
Run Code Online (Sandbox Code Playgroud)