require.js同步加载 [英] require.js synchronous loading

查看:571
本文介绍了require.js同步加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想定义一个模块,该模块计算新的依赖关系,获取它,然后返回结果.像这样:

I'd like to define a module which computes a new dependancy, fetches it and then returns the result. Like so:

define(['defaults', 'get_config_name'], function(defaults, get_config_name) {
    var name = get_config_name();
    var config;
    require.synchronous([configs / '+name'], function(a) {
        config = defaults.extend(a);
    });
    return config;
});

是否有解决此问题的方法或更好的方法?

Is there a way to do this or a better way to attack this problem?

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆