Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //moduleA.js
- define(function () {
- return Math.ceil(Math.random(100) * 100);
- });
- //moduleB.js
- define(['moduleA'], function (module) {
- return module;
- });
- //moduleC.js
- define(['moduleA'], function (module) {
- return module;
- });
- //main.js
- define(['moduleA', 'moduleB', 'moduleC'], function (moduleA, moduleB, moduleC) {
- var html =
- '<div>' + moduleA + '</div>' +
- '<div>' + moduleB + '</div>' +
- '<div>' + moduleC + '</div>';
- document.getElementsByTagName('body')[0].innerHTML = html;
- });
- // test.html
- <!DOCTYPE HTML>
- <html>
- <head>
- <style type="text/css">
- body {
- font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
- padding: 3em;
- }
- </style>
- <script type="text/javascript" data-main="main.js" src="require.js"></script>
- </head>
- <body>
- </body>
- </html>
- /*--->
- 42
- 42
- 42
- */
Advertisement
Add Comment
Please, Sign In to add comment