2013-07-06 41 views
0

在我簡單的索引文件,我添加了「requirejs」 - 和調用定義功能,但我沒有得到任何迴應:requirejs - 我沒有得到加載和「規定」,不叫功能

HTML:

<!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Document</title> 
</head> 
<body> 
    <script data-main="js/main" src="js/lib/require.js"></script> 
</body> 
</html> 

main.js:

require.config({ 
    baseUrl : "js" 
}) 

require(function() { 
    alert("hi"); 
}) 

回答

0

我找到了解決方案:它描述爲:

require(["helper/util"], function(util) { 
    //This function is called when scripts/helper/util.js is loaded. 
    //If util.js calls define(), then this function is not fired until 
    //util's dependencies have loaded, and the util argument will hold 
    //the module value for "helper/util". 
}); 

at here:http://requirejs.org/docs/start.html

謝謝大家。