项目结构
sea-demo
sea.html
sea.js
assert
admin.js
user.js
sea.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>hello sea</title> <script type="text/javascript" src="sea.js"></script> </head> <body> <script type="text/javascript"> seajs.config({ base:'assert/' }); seajs.use(['user','admin'],function(user,admin){ user.show(); admin.show(); }); </script> </body> </html>
user.js
define(function(require,exports,module){ var admin = require('admin'); admin.show(); exports.show=function(){ alert('I am user! '); } });
admin.js
define(function(require,exports,module){ exports.show=function(){ alert(' I am admin! '); } });