如何从窗口小部件内部获取dojo模块路径

时间:2015-10-22 15:09:30

标签: javascript dojo

我有dojoConfig如下:

plot.new_class

如何从另一个已加载的模块或小部件内部访问var base = location.href.split("/"); base.pop(); base = base.join("/"); var dojoConfig = { async: true, parseOnLoad: false, isDebug: false, packages: [{ name: "library", location: base + '/js/lib' }, { name: 'widgets', location: base + '/js/widgets' }]; location

1 个答案:

答案 0 :(得分:0)

所以从official site开始,dojo/require会这样做。

以下是一个例子:

require(["dojo/_base/xhr", "dojo/dom"], function(xhr, dom){
     // points to $dojoroot/dijit/form/tests/TestFile.html
     var url = require.toUrl("dijit/form/tests/TestFile.html");
     xhr.get({
         url: url,
         load: function(html){
             dom.byId("foo").innerHTML = html;
         }
     });
});