requirejs - 我没有加载并且没有调用“require”函数

时间:2013-07-06 05:42:09

标签: requirejs

在我的简单索引文件中,我添加了“requirejs” - 并调用了define函数,但我没有得到任何响应:

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");
})

1 个答案:

答案 0 :(得分: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".
});

在这里:http://requirejs.org/docs/start.html

感谢所有人。

相关问题