2015-06-02 31 views
-1

我有加載模塊index.html爲:要求JS不是從CONFIGS

<!DOCTYPE html> 
<html> 
    <head> 
     <script data-main="scripts/main" src="lib/require.js"></script> 
    </head> 
    <body> 
     <h1>Example 1: basic usage</h1> 
    </body> 
</html> 

main.js

requirejs.config({ 
    waitSeconds: 200, 
    paths: { 
     "app": "app" 
    } 
}); 

app.js

define(function() { 
    alert('Hello World'); 
}); 

兩個mainapp都在之下文件夾。

當我打開index.html,並在控制檯,如果我給:

require("app") 

我得到這樣的錯誤:

Uncaught Error: Module name "app" has not been loaded yet for context: _. Use require([]) 

不知道,在那裏我已經錯了。

回答