angularJS 路由不能正常工作 URL中出现#!
来源:互联网 发布:机加工成本计算软件 编辑:程序博客网 时间:2024/06/08 02:16
原文来自 http://blog.csdn.net/github_38469481/article/details/70598066
使用ng-route大于1.6.0的版本时,地址中的 "/" 会自动被解析 而且还会在URL地址中加入#! 导致路由不能正常的工作
如图所示
解决此问题的方法有两种 :
1、如果坚持使用当前版本的angular则在配置路由时添加如下代码
$locationProvider.hashPrefix('');
代码如下所示
var myApp= angular.module('myApp',['ngRoute']);
myApp.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider){
//这是因为Angular 1.6 版本更新后 对路由做的处理,这样才可以和以前版本一样正常使用
$locationProvider.hashPrefix('');
$routeProvider
.when('/RuKu',{
controller:'Acontroller',
templateUrl:"./viewes/viw1.html",
})
.when('/OrderDetial',{
controller:'Bcontroller',
templateUrl:"./viewes/viw2.html"
})
.otherwise('/RuKu');
}]);
效果如下所示 路由可以正常工作
2、使用比1.6.0的低的版本。
阅读全文
0 0
- angularJS 路由不能正常工作 URL中出现#!
- angularJS 路由不能正常工作 URL中出现#!
- win7 安装ie11 出现f12 不能正常工作
- angularjs 路由 不能嵌套问题
- angularjs中关于路由
- 让Reflector不能正常工作
- node-readability不能正常工作
- angularJS中repeat数据不能出现重复项解决
- angularJS中repeat数据不能出现重复项解决
- IIS7/Win7中使用Intelligencia.UrlRewriter实现url重写时候不能正常使用原因
- IIS7/Win7中使用Intelligencia.UrlRewriter实现url重写时候不能正常使用原因
- 让Reflector的反编译不能正常工作
- windows7 下SVN不能正常工作
- Struts2部署之后servlet不能正常工作
- Hadoop DataNode不能正常工作的原因
- window8 下PEiD不能正常工作
- VS2010数据库项目不能正常工作解决方案
- Xcode插件不能正常工作解决方法
- ubuntu libnice编译测试
- hannnnah_j’s Biological Test HDU
- Codeforces 190E Counter Attack【思维+Bfs】好题!
- CentOS7使用firewalld打开关闭防火墙与端口
- 将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5
- angularJS 路由不能正常工作 URL中出现#!
- 归并排序
- 心情随笔
- 正则表达式小结
- java中的线程、进程、锁
- tomcat 优化
- echo框架使用:获取与配置
- ubuntu 下PyCharm下如何使用flask创建pythonproject
- [绍棠] IQKeyboardManager的使用