extends
或
implements
在Java中,但在运行时)。我提出了以下解决方案:
var declaredClassBackup = this.declaredClass; // backup the "declaredClass"
var mixinObject = null;
try {
dojo.require(kwArgs.mixinClassName);
/*
* Eval the mixinClassName variable to get the Function reference,
* then call it as a constructor with our mixinSettings
*/
mixinObject = new (eval(kwArgs.mixinClassName))(kwArgs.mixinSettings);
} catch (e){
if(console){
console.error("%s could not be loaded as a mixin.",
kwArgs.mixinClassName);
}
mixinObject = new package.path.DefaultMixin(kwArgs.mixinSettings);
}
dojo.mixin(this, mixinObject);
/*
* Re-set the declaredClass name back to that of this class.
*/
this.declaredClass = declaredClassBackup;
如果有什么问题的话,这种类型的代码会出什么问题?(如何使它更健壮?)另外,在dojo中是否有我可能错过的东西可以让我更优雅地完成这项工作?