如何知道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>
感谢!!!
答案 0 :(得分:0)
你必须把
window.reqapi.getModule('test');
到这样的结构:
require([
// Load our app module and pass it to our definition function
'{{your module}}'
],
function(reqapi){
reqapi.getModule('test');
});