~$ 存档

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

主页代码:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script>
        var dojoConfig = {
            packages: [{

                //包名(称为包更容易理解,包是一系列模块的集合);
                name: "A",
                //包映射的路径(在此设置为根目录下的js/modules之下;
                location: location.pathname.replace(/\/[^/]+$/, "") + "/js/modules"

            }]
        };
    </script>
    <script src="http://js.arcgis.com/3.9/"></script>
    <script type="text/javascript">
        require(["A/demo"], function (demo) {
            demo.f();
        });
    </script>
</head>
<body>

</body>
</html>

模块代码(demo.js):

/*此模块没有依赖项,只做简单的测试*/

define(function () {
    var a = {
        f: function () {
            alert("f()执行!");
        }
    };
    return a;/*返回一个对象*/
})

目录结构图:

posted on 2017-07-26 00:49  LuoTian  阅读(206)  评论(0编辑  收藏  举报