我正在尝试使用<代码>dojo.require(If),其中含有一个地方变量,以动态方式将一个基于条件页的单元装上。
// note: dojo v1.4 djConfig = { debugAtAllCosts: true };
<>Exstrong>Example 1 (does not work):
(function() { var nameOfClass = "Two"; dojo.require("my.namespace." + nameOfClass); dojo.addOnLoad(function() { var oneOrTwo = new my.namespace[nameOfClass](); }); }());
Error: ReferenceError: nameOfClass is not defined.
<>Exstrong>Example 2 (does not work):
(function() { var nameOfClass = "Two"; dojo.requireIf(nameOfClass == "One", "my.namespace.One"); dojo.requireIf(nameOfClass == "Two", "my.namespace.Two"); dojo.addOnLoad(function() { var oneOrTwo = new my.namespace[nameOfClass](); }); }());
Error: ReferenceError: nameOfClass is not defined.
www.un.org/Depts/DGACM/index_french.htm
(function() { window.nameOfClass = "Two"; dojo.requireIf(window.nameOfClass == "One", "my.namespace.One"); dojo.requireIf(window.nameOfClass == "Two", "my.namespace.Two"); dojo.addOnLoad(function() { var oneOrTwo = new my.namespace[nameOfClass](); }); }());
出于某种原因,它似乎既需要又需要。 如果只允许其中的全球变量。 这是否是一种目前的限制,还是我刚刚做过错?
<>Update 1
因此,如果我正确理解你(@Maine,@jrburke)的话,这是对德布古斯塔斯的限制? 如果上述法典是作为交叉主体制定的(处理Xd文档预设文件/文件),并且已经执行——它将按预期运作?
如果情况是这样,那么在不实际建造的情况下,作为交叉主实施的当地测试法的恰当方式是什么?
这也使我怀疑预先安排工作的动力。 如果装货人(或者说不能)预先准备,为什么为测试/拆卸而建立的方法?
<>Update 2
由于上文增编1中的两个问题与这个问题没有密切关系,我将其移至。