目录结构
文件1:sea-debug.js是官方的依赖文件
文件2:test.html文件内容
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://www.domain.com/seajs/assets/global/js/sea-debug.js"></script>
</head>
<body>
<script type="text/javascript">
seajs.config({
base: "http://www.domain.com/seajs/assets/",
alias: {
"jquery": "global/js/jquery-1.8.3.js",
}
});
seajs.use("modules/module1/define", function(module1) {
module1.console('modules/module1/define');
});
</script>
</body>
</html>
文件3:define.js文件
写法一:
define(['jquery'],function(require,exports,mod) {
console.log('write type 1...');
return {
console : function(str){
console.log(str);
}
};
});
写法二:
define(['jquery'],function(require,exports,mod) {
console.log('write type 2...');
exports.console = function(str){
console.log(str);
};
});
写法三:
define(['jquery'],function(require,exports,mod) {
console.log('write type 3...');
mod.exports = {
console : function(str){
console.log(str);
}
};
});