Dojo and Asynchronous Module Definition(AMD)

The JavaScript doing the actual work is the same in both the older style of modules with dojo.declare and the newer AMD style.

The big differences between legacy and AMD modules are how they are defined (dojo.declare() vs. define()) and how they are loaded (dojo.require() vs. require()).

legacy:

<script type="text/javascript">
dojo.require("esri.map");
function init() {
var myMap = new esri.Map("mapDiv");
//note that if you do not have public Internet access then you will need to point this url to your own locally accesible cached service.
var myTiledMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost:8399/rest/services/demo/MapServer");
myMap.addLayer(myTiledMapServiceLayer);
}
dojo.addOnLoad(init);
</script>
View Code

AMD:

posted @ 2013-11-30 12:17  StonySven  阅读(215)  评论(0编辑  收藏  举报