RequireJS:从其他上下文加载模块

时间:2014-10-07 15:31:32

标签: javascript requirejs

我有两个需要配置(两个上下文),如下所示:

var requirePortal = require.config({
    context: 'portal',
    baseUrl: '',
    paths: {
        'jquery': 'assets/js-vendors/jquery/dist/jquery',
        'underscore': 'assets/js-vendors/underscore/underscore',
        'backbone': 'assets/js-vendors/backbone/backbone',
        // ...
    }
});

var requireSample = require.config({
    context: 'sample',
    baseUrl: '<adress>/other-context',
    paths: {
        'viewFactory': 'application/util/ViewFactory',
        'indicador':   'application/models/indicador'
    }
});

此处门户上下文将包含所有供应商组件,示例上下文将包含用例模块。然后我必须从样本上下文中加载供应商组件:

define([
    'indicador'
], function(IndicadorModel) {
    var IndicadorPagerCollection = PagerCollection.extend({
        model: IndicadorModel,
        baseUrl: 'rest/manter/indicadores'
    });
    return IndicadorPagerCollection;
});

在这种情况下,PagerCollection是供应商组件,位于门户网站上下文中。我怎么能这样做?

0 个答案:

没有答案