0

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

网页:

<!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>

主.js:

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

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

1 回答 1

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

谢谢大家。

于 2013-07-06T07:39:20.137 回答