0

想象一下:

var derivedFrom = [someMixin];

declare(derivedFrom, {
    // ...
});

每次我创建此模块的新实例时,这都会派生自 someMixin 。

想象一下,现在我想添加一个参数,这样 someMixin 只会被加载并从 true 派生:

var derivedFrom = [];

declare(derivedFrom, {
    constructor: function (options) {
        if (options.someCondition)
            require(['some/mixin'], function (someMixin) {
                derivedFrom.push(someMixin);
            });
    }
});

这样的事情可以实现吗?

4

0 回答 0