从AOL加载Dojo库和从本地加载小部件代码? [英] Loading Dojo Library from AOL and Widget Codes from Local?

查看:82
本文介绍了从AOL加载Dojo库和从本地加载小部件代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习Dojo。我遵循一个网站Widget示例,以一些不同的方式加载Dojo库。我喜欢使用AOL参考来加载这样的dojo.js:

 < script type =text / javascript
src =http://o.aolcdn.com/dojo/1.2.0/dojo/dojo.xd.js>
< / script>

并将我的小部件代码保存在本地Web服务器中,如下所示:

  scripts / 
myWidget /
widgetExample.js
...
test.html

其中 widgetExample.js 包含我的小部件类代码,而 test.html 是我的测试页面。我得到的错误消息是:未捕获的异常:无法加载跨域资源: myWidget.widgetExample ...。我不知道我是否必须在本地加载dojo包?我真的很喜欢将dojo库包从它们分开或从AOL加载,并将自己的代码放在本地路径中。我试图google关于不同的域加载,baseScriptUrl和moduleMapping?仍然无法弄清楚。感谢任何详细说明。

解决方案

这可能有助于: http://dojotoolkit.org/forum / dojo-core-dojo-0-9 / dojo-core-support / xdomain-usage-dojo-loading-not-detection-local-modules





djConfig = {modulePaths:{mine:/ js / mine};



可以从/js/mine/Thing.js doj.require(mine.Thing)

关于
Peter Higgins


I just started to learn Dojo. I followed one site Widget example with some different ways to load Dojo libraries. I like to use AOL reference to load dojo.js like this:

<script type="text/javascript" 
  src="http://o.aolcdn.com/dojo/1.2.0/dojo/dojo.xd.js">
</script>

and saved my widget codes in local web server like this:

scripts/
   myWidget/
     widgetExample.js
   ...
test.html

where widgetExample.js contains my widget class codes, and test.html is my testing page. The error message I got is: "uncaught exception: Could not load cross-domain resources: myWidget.widgetExample ...". I am not sure if I have to load dojo package locally? I really like to separate dojo library package as they are or loaded from AOL and only put my own codes in a local path. I tried to google about different domain loading, baseScriptUrl, and moduleMapping? Still not be able to figure out. Thanks for any detail instructions if any.

解决方案

This may help: http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/xdomain-usage-dojo-loading-not-detecting-local-modules

The summary is: you need a djConfig item registering the modulePaths you want to be local, and specify a baseUrl to "trick" Dojo into thinking it knows where those paths are relative, across hosts.

djConfig = { modulePaths: { "mine":"/js/mine" };

then you can dojo.require("mine.Thing") from /js/mine/Thing.js

Regards, Peter Higgins

这篇关于从AOL加载Dojo库和从本地加载小部件代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆