seajs 的研究一 --- 無題

weixin_33831673發表於2013-05-19

main.js

define(function(require, exports, module) {

	var person = require("../test/test2.js");
	var module3 = require("../test/test3.js");

	var main = {}

	main.init = function(){
		module3.init();
	}
	
	module.exports = main;
});

test1.js

define(function(require, exports, module) {

	var object = {};

	module.exports = object;
});

test2.js

define(function(require, exports, module) {
	var module1 = require("./test1");

	var object = {"name":"lifeixiang"};

	module1.preson = object;

	module.exports = object;
});

test3.js

define(function(require, exports, module) {
	var module1 = require("./test1");

	var object = {};

	object.init = function(){
		console.log(module1.preson)
	}

	module.exports = object;
});

相關文章