sea.js demo

index.html

<script type="text/javascript" src="js/sea.js"></script>
<script type="text/javascript">
	// seajs 的简单配置
	seajs.config({
	  base: "./js/",
	  alias: {
	    "jquery": "jquery-1.11.1.min.js"
	  }
	});

	// 加载入口模块
	seajs.use("main");
</script>

main.js

// 所有模块都通过 define 来定义
define(function(require, exports, module) {

	require('jquery');
	console.log(1111);
	var index = require('index');
	console.log(index);
	console.log(index.doSomething());

	console.log(module);

	/*var index = require.async('index', function(index_callback){
		console.log(index_callback.doSomething());
	});*/

});

index.js

// 所有模块都通过 define 来定义
define(function(require, exports, module) {

  /*exports.doSomething = function(){
  	console.log('do something');
  }*/
  var a = {};
  a.doSomething = function(){
  	console.log('do something');
  }
   a.doSomething2 = function(){
  	console.log('do other things');
  }

  module.exports = a;

});

  

你可能感兴趣的:(sea.js demo)