页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script data-main="js/base.js?v=12121" src="http://apps.bdimg.com/libs/require.js/2.1.9/require.js"></script>
</body>
</html>
base.js
requirejs.config({
urlArgs : 1234223233232,
baseUrl: 'js/lib',
paths: {
app: '../app',
"jquery" : 'http://apps.bdimg.com/libs/jquery/1.7.2/jquery.min'
}
});
requirejs(['jquery', 'sayHello'], function($, s) {
console.log($.toString());
});
sayHello.js
(function() {
var hello = function() {
var say = function() {
alert("hello");
};
return {
say : say
}
}();
if (typeof define === 'function' && define.amd) {
define('sayHello', ['jquery'], function($) {
console.log("hello" + $(window).width());
return hello;
});
}
return hello;
})();