我想我没有按要求使用 dojo.mixin ......
我有以下代码:
dojo.declare("A",null,{
_configuration: {},
constructor: function(configuration)
{
if(this._configuration.something === 2)
{
// we should never come here; the constructor is only called on a new instance which should still have an empty _somethingPrivate
// because the class declaration says so
console.log("why does this happen?");
}
// merge empty configuration
dojo.mixin(this._configuration, configuration);
}
});
var myInstance = new A({ something: 2 });
var myInstance = new A({});
据我了解,您可以使用 dojo.mixin 来合并对象。我尝试将默认配置对象与给定参数(在对象中)合并,但控制台输出是“为什么会发生这种情况?” 因此来自先前对象的参数被合并到一个新对象中。
任何人都可以对此有所了解吗?
顺便说一句:dojo 1.6 版(我们还不能升级)