想象一下:
var derivedFrom = [someMixin];
declare(derivedFrom, {
// ...
});
每次创建此模块的新实例时,都会从someMixin派生。
想象一下,现在我想添加一个参数,以便someMixin只会加载并派生自if:
var derivedFrom = [];
declare(derivedFrom, {
constructor: function (options) {
if (options.someCondition)
require(['some/mixin'], function (someMixin) {
derivedFrom.push(someMixin);
});
}
});
可以实现这样的目标吗?