主页代码:
<!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;/*返回一个对象*/
})
目录结构图: