2013-07-06 35 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

谢谢大家。