angularjs – Ui-sref不在URL中生成哈希值(Angular 1.3.0-rc.3)
发布时间:2020-12-17 17:40:53 所属栏目:安全 来源:网络整理
导读:从Angular 1.3.0 RC-2升级到RC-3后,ui-sref生成的链接中的哈希符号消失了.该链接是可点击的,状态传输正确,但如果我复制链接地址并将其粘贴到浏览器中,它将落在错误的页面上.我不想使用 HTML5Mode. 1.3.0 rc.2 !DOCTYPE html html head link rel="stylesheet"
从Angular 1.3.0 RC-2升级到RC-3后,ui-sref生成的链接中的哈希符号消失了.该链接是可点击的,状态传输正确,但如果我复制链接地址并将其粘贴到浏览器中,它将落在错误的页面上.我不想使用
HTML5Mode.
1.3.0 rc.2 <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body ng-app="myApp"> <div ui-view></div> <script src="https://code.angularjs.org/1.3.0-rc.2/angular.js"></script> <script src="https://rawgit.com/angular-ui/ui-router/0.2.11/release/angular-ui-router.js"></script> <script> angular.module('myApp',['ui.router']) .config(function($stateProvider,$urlRouterProvider,$locationProvider) { $urlRouterProvider.otherwise('/foo'); $stateProvider.state('foo',{ url: '/foo',template: 'This is foo <a ui-sref="foo.bar">Go to bar</a><div ui-view></div>' }) .state('foo.bar',{ url: '/bar',template: 'This is bar' }) $locationProvider.html5Mode(false); //$locationProvider.html5Mode({ enabled: false }) }); </script> </body> </html> Plunkr demonstrating working example 1.3.0 rc.4 <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="style.css"> </head> <body ng-app="myApp"> <div ui-view></div> <script src="https://code.angularjs.org/1.3.0-rc.4/angular.js"></script> <script src="https://rawgit.com/angular-ui/ui-router/0.2.11/release/angular-ui-router.js"></script> <script> angular.module('myApp',template: 'This is bar' }) //$locationProvider.html5Mode(false); $locationProvider.html5Mode({ enabled: false }) }); </script> </body> </html> Plunkr demonstrating the problem 我做错了什么,或者ui-router与最新的Angular候选版本不兼容? 解决方法
这是一个众所周知的问题.它固定在主人身上.
https://github.com/angular-ui/ui-router/issues/1397 Angular 1.3更改了HTML5模式API,UI-Router必须支持任一API. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |