AngularJS采用ocLazyLoad第三方库,按需加载。在JS中,配置路由的代码如下:
function config($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/index");
$stateProvider
.state('itemList', {
url: "/itemList",
templateUrl: "views/itemList/itemList.html",
controller: 'itemListCtrl',
resolve: {
loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad){
return $ocLazyLoad.load('js/itemList/itemList.js')
}]
},
params:{
data:null, //数据{SORTCODE、DEPTID、searchType}
}
})
}
angular
.module('app')
.config(config)
.run(function($rootScope, $state) {
$rootScope.$state = $state;
});
在Chrome中查看页面的时候,一切正常,但是在iOS App 利用UIWebView来加载页面的时候,点击跳转会出现
Failed to load resource: The requested URL was not found on this server
没有加载到对应的资源。
原因:UIWebView对于路径URL判定,大写和小写是不一样,但是Chrome可以。
比如路径url写的是js/itemList/itemList.js
,实际上是js/ItemList/itemList.js
(或者后缀问题,如:路径url写的是views/itemList/itemList.html
实际上是 views/itemList/itemList.HTML
)
所以导致我平时用Chrome调试可以正常跑通,但是加载到UIWebView上的时候,大小写差异是不一样的路径。
问题记录下