我正在使用dojo 1.10。
这是我的主要剧本:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Title</title>
<link rel="stylesheet" href="http://SERVERABC/arcgis_js_api/library/3.10/3.10/js/esri/css/esri.css"/>
<style id="myStyle">
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
font-family: Arial, Calibri, Times New Roman;
}
textarea, input[type="text"]
{
font-family: Arial, Calibri, Times New Roman;
font-size: 12px;
}
</style>
<script type="text/javascript" src="js/common.js"></script>
<script>
dojoConfig = {
packages: [
{ name: "js", location: "/js" }
]
};
</script>
<script src="http://SERVERABC/arcgis_js_api/library/3.10/3.10/init.js" ></script>
<script>
var map;
var streetMap;
var imageryMap;
require(["esri/map",
"esri/config",
"esri/layers/FeatureLayer",
"esri/geometry/webMercatorUtils",
"esri/geometry/Extent",
"esri/layers/ArcGISTiledMapServiceLayer",
"js/parameters",
"dojo/fx",
"dojo/window",
"dojo/parser",
"dojo/on",
"dojo/dom",
"dojo/dom-geometry",
"dojo/domReady!"], function (Map, esriConfig, FeatureLayer, webMercatorUtils, Extent, ArcGISTiledMapServiceLayer, Parameters, coreFx, win, parser, on, dom, domGeom) {
esriConfig.defaults.io.proxyUrl = "proxy.ashx";
esriConfig.defaults.io.alwaysUseProxy = false;
parser.parse();
map = new Map("map", {
center: [114.220118, 22.317574], // longitude, latitude
zoom: 1,
showAttribution: false,
lods: [
// { "level": 6, "resolution": 2445.98490512499, "scale": 9244648.868618 },
// { "level": 7, "resolution": 1222.99245256249, "scale": 4622324.434309 },
// { "level": 8, "resolution": 611.49622628138, "scale": 2311162.217155 },
// { "level": 9, "resolution": 305.748113140558, "scale": 1155581.108577 },
// { "level": 10, "resolution": 152.874056570411, "scale": 577790.554289 },
// { "level": 11, "resolution": 76.4370282850732, "scale": 288895.277144 },
// { "level": 12, "resolution": 38.2185141425366, "scale": 144447.638572 },
// { "level": 13, "resolution": 19.1092570712683, "scale": 72223.819286 },
{"level": 14, "resolution": 9.55462853563415, "scale": 36111.909643 },
{ "level": 15, "resolution": 4.77731426794937, "scale": 18055.954822 },
{ "level": 16, "resolution": 2.38865713397468, "scale": 9027.977411 },
{ "level": 17, "resolution": 1.1943285668550503, "scale": 4513.988705 },
{ "level": 18, "resolution": 0.5971642835598172, "scale": 2256.994353 },
{ "level": 19, "resolution": 0.29858214164761665, "scale": 1128.497176 }
]
});
streetMap = new ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer", {
id: "streetMap"
});
imageryMap = new ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer", {
id: "imageryMap"
});
map.addLayer(streetMap);
map.addLayer(imageryMap);
imageryMap.hide();
onlyForTesting();
map.on("load", function () {
map.resize();
});
});
</script>
</head>
<body>
<div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%; height:100%;">
<div id="header" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">
<div id="languagesContainer"></div>
</div>
<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" baseClass="dijitContentPaneNoPadding"></div>
</div>
</body>
</html>
此HTML文件应加载另一个名为parameters.js的.js文件,该文件位于js文件夹中。 js文件夹和HTML文件位于同一文件夹(同一级别)。
它正在本地计算机上运行。我可以创建并获取从js /参数加载的Parameter模块的对象。但是当我将所有网站文件移动到SERVERABC机器(在IIS7的wwwroot内)WIndows Server 2008 R2时,脚本将无法正常运行。它停在中间,没有任何显示。如果我删除Require中的“js / parameters”(并删除“Parameters”变量),它将只能正常运行。
一个脚本如何在计算机上运行但在另一个脚本上不起作用?我必须先在Server机上做任何设置吗?请注意,当我在本地计算机上运行脚本或从服务器SERVERABC运行脚本时,所有Dojo javascript引用文件都位于SERVERABC机器中。
非常感谢任何想法或解决方案。
答案 0 :(得分:1)
我会尝试在其余代码之前立即在一个位置加载所有脚本。所以我们这样做。您是否检查过服务器上的目录是否与本地计算机具有相同的结构?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Title</title>
<link rel="stylesheet" href="http://SERVERABC/arcgis_js_api/library/3.10/3.10/js/esri/css/esri.css"/>
<script src="http://SERVERABC/arcgis_js_api/library/3.10/3.10/init.js" ></script>
//load all necessary Scripts
<script type="text/javascript" src="js/common.js"></script>
....and so on