FK JavaScript:ArcGIS JavaScript类库加载不成功而导致的程序异常

现象:页面加载时,有时候成功,有时候出错,出错的地方为init.js 加载esri的类库

经过仔细对比,发现出错时dojo加载的类库中,对象的很多属性都为undefined,而加载成功时,该对象的相关属性都是有值的

加载成功与否基本是随机的.

错误提示:

Uncaught TypeError: Cannot read property 'toLowerCase' of null

目前遇到类似的问题,一般情况出错消息都是上句

出错语句:

出错原因:JQuery类库与Dojo类库产生的冲突,应该是JQuery类库与函数冲突了dojo类库的加载

解决方法:参考下述网址.老外给出了多种解决方案

采用下面的方法,解决了问题(其他方法没有测试):

When jQuery and/or jQuery UI haven't finished loading their modules/scripts but dojo is starting to load, the above if statement seems to prove to be true. Whoever, when you defer loading all dojo stuff until jQuery-ui and jQuery are loaded, the statement will return false (obviously).

I haven't been able to fully test the hypothesis but in practice this works for me:

- load jQuery and jQuery ui in de header, blocking

- load alle my custom code AND the dojo stuff in the footer, deferred

做法就是:在页面的header标签中加载JQuery相关类库

在页面的最下方,加载ArcGIS JavaScript的类库

参考:https://geonet.esri.com/thread/119518

posted @ 2016-05-26 10:29  DayDreamInGIS  阅读(865)  评论(0编辑  收藏  举报