ArcGIS中加载模块时dojo/domReady!和dojo/ready的区别
我們在使用ArcGIS Javascript? API開發時,最開始要先加載模塊:
<script>require(["esri/map", "dojo/domReady!"], function(Map) {// code to create the map and add a basemap will go here}); </script>這里有個dojo/domReady!,另外Dojo還有一個dojo/ready,這倆有啥區別呢,esri官網上有這么一段:
The difference between?domReady?and?ready?is that the former waits to fire the callback provided to?require?until the DOM is available while the latter waits for the DOM to be ready?and?waits for all outstanding require calls to finish. For more information, see the?Dojo documentation for dojo/ready. In simple cases,?dojo/domReady!?should be used. If an app uses?parseOnLoad: true, Dojo Dijits, widgets from the Esri library or custom dijits,?dojo/ready?should be used.
翻譯過來就是,domReady是等待所有DOM元素加載完成,再require相關模塊;而ready是等待DOM元素加載以及require的相關模塊全部加載完成。在一些簡單應用場景,用dojo/domReady!就行了;如果應用里需要用到一些組件,微件之類的還是用dojo/ready.
總結
以上是生活随笔為你收集整理的ArcGIS中加载模块时dojo/domReady!和dojo/ready的区别的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 高德地图和百度地图接口封装遇到的问题(三
- 下一篇: 运行Angular项目后自动打开网页