【发布时间】:2016-10-12 07:58:56
【问题描述】:
我猜是关于 main.js,但我已经尝试了我在网上找到的所有示例,但它们都不起作用。
我目前有:三个模块(one.js、two.js、three.js)、main.js、index.html 和一些参考文件,如 require.js
one.js:
define("one",['./two', './three'], function(two, three) {
var one = 1;
return {
value: function(e){
return one;
}
}
});
two.js:
define("two",['./one', './three'], function(one, three) {
var two = 2;
return {
value: function(){
return two;
}
}
});
main.js:
require(["one", "two", "three"], function (one, two, three) {
});
我的 HTML:
<html>
<head>
<title>My App</title>
<script data-main="scripts/main" src="scripts/require.js"></script>
</head>
// the function from two.js having the same name as another in one.js needs to be called here.
<body onload="value();">
<h1>My App</h1>
</body>
</html>
【问题讨论】:
标签: javascript requirejs