【问题标题】:how to judge the require.js end of the load all modules in global scope如何判断加载全局范围内所有模块的require.js结束
【发布时间】:2013-07-17 02:52:01
【问题描述】:

如何知道 require.js 加载了全局范围内的所有模块? 例如:

<html>
    ...
<script src="require.min.js" data-main="main.js"></script>
<body>
    ...
    <script type="text/javascript">
        if(loaded) { //if loaded all modules call a function in some modules
            window.reqapi.getModule('test');
        }
    </script>
    ...
</body>
</html>

谢谢!!!

【问题讨论】:

    标签: javascript requirejs js-amd


    【解决方案1】:

    你必须放

    window.reqapi.getModule('test');
    

    到这样的结构:

    require([ 
        // Load our app module and pass it to our definition function 
        '{{your module}}'
    ], 
    function(reqapi){ 
        reqapi.getModule('test');
    }); 
    

    【讨论】:

      猜你喜欢
      • 2013-03-23
      • 2012-07-30
      • 1970-01-01
      • 2018-11-25
      • 2011-08-27
      • 2015-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多