国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術(shù)文章
文章詳情頁

angular.js - angularjs中路由的HTML5模式下的URL問題

瀏覽:99日期:2023-01-12 14:52:46

問題描述

在angularjs的路由中使用HTML5模式,結(jié)果無法加載模版(templateUrl沒有發(fā)送http請(qǐng)求),而且URL中還出現(xiàn)的轉(zhuǎn)義。但使用標(biāo)簽?zāi)J綍r(shí)一切OK,求大佬告知?<!DOCTYPE html><html lang='en'><head>

<meta charset='UTF-8'><base href='http://www.cgvv.com.cn/' ><title>Title</title><script src='http://www.cgvv.com.cn/wenda/angular.min.js'></script><script src='http://www.cgvv.com.cn/wenda/angular-route.min.js'></script><script> angular.module(’myApp’,[’ngRoute’]) .config([’$routeProvider’,’$locationProvider’,function($routeProvider,$locationProvider){$locationProvider.html5Mode(true);$routeProvider.when(’/first’,{ controller:’firstCtrl’, templateUrl:’1.html’}).when(’/second’,{ controller:’secondCtrl’, templateUrl:’2.html’}).otherwise({ redirectTo:’/first’}); }]) .controller(’myController’,function($scope,$http,$window){ }) .controller(’firstCtrl’,function($scope,$http){ }) .controller(’secondCtrl’,function($scope,$http){ });</script>

</head><body ng-app='myApp' ng-controller='myController'><p>

<a href='http://www.cgvv.com.cn/wenda/3466.html#/first'>first</a><a href='http://www.cgvv.com.cn/wenda/3466.html#/second'>second</a>

</p><p ng-view></p></body></html>

angular.js - angularjs中路由的HTML5模式下的URL問題

問題解答

回答1:

目錄結(jié)構(gòu)angular.js - angularjs中路由的HTML5模式下的URL問題

模板1 - templates/1.html

<h2>First Html</h2>

模板2 - templates/1.html

<h2>Second Html</h2>

<!DOCTYPE html><html><head> <meta charset='utf-8'> <meta name='viewport' content='width=device-width'> <title>Angular Demo</title> <!--后面需根據(jù)部署后的實(shí)際路徑做調(diào)整--> <base href='http://www.cgvv.com.cn/' > <script src='https://cdn.bootcss.com/angular.js/1.5.11/angular.min.js'></script> <script src='https://cdn.bootcss.com/angular.js/1.5.11/angular-route.min.js'></script></head><body ng-app='myApp' ng-controller='myController'><p> <a href='http://www.cgvv.com.cn/first'>first</a> <a href='http://www.cgvv.com.cn/second'>second</a></p><p ng-view></p><script> angular.module(’myApp’,[’ngRoute’]) .config([’$routeProvider’,’$locationProvider’,function($routeProvider,$locationProvider){$locationProvider.html5Mode(true);$routeProvider.when(’/first’,{ controller:’firstCtrl’, templateUrl:’templates/1.html’}).when(’/second’,{ controller:’secondCtrl’, templateUrl:’templates/2.html’}).otherwise({ redirectTo:’first’}); }]) .controller(’myController’,function($scope,$http,$window){ }) .controller(’firstCtrl’,function($scope,$http){ }) .controller(’secondCtrl’,function($scope,$http){ });</script></body></html>

另外路由建議使用 ui-router

參考資料

Angularjs html5mode模式路由

angular路由去掉的URL里的#號(hào)

標(biāo)簽: Html5
相關(guān)文章:
主站蜘蛛池模板: 久久精品免费全国观看国产 | 亚洲欧美日韩一区 | 在线成人精品国产区免费 | 亚洲一区二区三区四区五区 | 欧美jlzz18性欧美 | 国产美女操 | 精品手机在线视频 | 真人一级毛片全部免 | 99久久国产免费 - 99久久国产免费 | 国产午夜三级 | 久久国产成人福利播放 | 九九免费视频 | 精品三级内地国产在线观看 | 日本黄色免费大片 | 性欧美另类老妇高清 | 国产在线高清不卡免费播放 | 九九精品免费观看在线 | 欧美亚洲国产精品久久高清 | 中文成人在线视频 | 亚洲一区二区免费视频 | 亚洲永久中文字幕在线 | 香蕉久久一区二区不卡无毒影院 | 九九热视频精品 | 精品欧美高清不卡在线 | 久草国产在线 | 男女上下爽无遮挡午夜免费视频 | 九草在线播放 | 精品一区二区三区在线观看l | 荡女妇边被c边呻吟久久 | 亚洲图片 自拍 | 亚洲欧美日韩综合在线一区二区三区 | 久久精品国内一区二区三区 | 国产一级精品毛片 | 亚洲一一在线 | 日本久久免费 | 国产三级精品美女三级 | 一区二区三区免费视频 www | 国产精品1区 2区 3区 | 精品国产一区在线观看 | 免费观看a级毛片在线播放 免费观看a级网站 | 久久亚洲综合 |