html5重新加载页面,使用AngularJSHTML 5模式重新加载页面会产生错误的GET请求
使用AngularJSHTML 5模式重新加載頁面會產生錯誤的GET請求
我想為我的應用程序啟用HTML 5模式。我已經為配置放置了以下代碼,如下所示這里:return?app.config(['$routeProvider','$locationProvider',?function($routeProvider,$locationProvider)?{
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix?=?'!';
$routeProvider.when('/',?{
templateUrl:?'/views/index.html',
controller:?'indexCtrl'
});
$routeProvider.when('/about',{
templateUrl:?'/views/about.html',
controller:?'AboutCtrl'
});
如你所見,我用了$locationProvider.html5mode我更改了我在ng-href排除/#/.
問題
現在,我可以去localhost:9000/并查看索引頁并導航到其他頁面,如localhost:9000/about.
但是,當我刷新localhost:9000/about一頁。我得到以下輸出:Cannot GET /about
如果我看一下網絡呼叫:Request?URL:localhost:9000/aboutRequest?Method:GET
如果我第一次去localhost:9000/然后單擊導航到/about我得到:Request?URL:http://localhost:9000/views/about.html
它完美地呈現了頁面。
當我刷新時,如何啟用角獲取正確的頁面?
總結
以上是生活随笔為你收集整理的html5重新加载页面,使用AngularJSHTML 5模式重新加载页面会产生错误的GET请求的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为鸿蒙系统2019年秋季上市,华为鸿蒙
- 下一篇: html页面获取服务器时间,[html]