我需要将dojo名称空间更改为其他名称。我找到了this stackoverflow帖子,但它引用了一个不再存在的dojo文档页面。以下是基于this页面尝试的内容,但无效:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" djConfig="scopeMap: [[ 'dojo', 'newns' ]]"></script>
<script>
newns.addOnLoad(function(){
console.debug("hello world");
});
</script>
</head>
<body>
</body>
</html>
帮助!
答案 0 :(得分:4)
我刚从旧的Dojo书中取出文档并将其放入新的doc系统中:
http://docs.dojocampus.org/multiversion/index
对于您的特定示例,需要在加载Dojo文件之前在脚本标记中声明djConfig对象,并且建议您也映射dijit和dojox:
<html>
<head>
<script>
var djConfig = {
scopeMap: [
['dojo', 'newns'],
['dijit', 'newnsw'],
['dojox', 'newnsx']
]
}
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js"></script>
<script>
newns.addOnLoad(function(){
console.debug("hello world");
});
</script>
</head>
<body>
</body>
</html>