添加AMD模块以从dojo / _base / declare的构造函数派生

时间:2013-09-06 13:22:22

标签: module dojo mixins amd

想象一下:

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);
            });
    }
});

可以实现这样的目标吗?

0 个答案:

没有答案