//test01.js--模块一
define(function(require,exports,module){//在我们自定义的js文件中,我们利用define来定义一个模块,define的第一个参数可以传递一个模块(可选),第二个参数是一个匿名函数,这个匿名函数中存在三个参数://1.require--模块加载函数,用于记载依赖模块//module--模块的元数据var test02=require("test02");
var test03=require("test03");
//2.exports--接口点,将数据或方法定义在其上则将其暴露给外部使用//依赖jquery库
exports.$=require("jquery-1.8.3");
exports.data3=test02.data3;
var data1="this is test01-data1";
//data2定义为公开
exports.data2="this is test01-data2";
functionfn1(){
console.log("this is test01-fn1");
}
fn1();
functionfn2(){
console.log("this is test01-fn2");
}
exports.fn3 = function(){
console.log("this is test01-fn3");
}
});
//test02.js--模块二
define(function(require,exports,module){var data1="this is test02-data1";
//data2定义为公开
exports.data2="this is test02-data2";
exports.data3="this is test02-data3";
functionfn1(){
console.log("this is test02-fn1");
}
fn1();
functionfn2(){
console.log("this is test02-fn2");
}
exports.fn3 = function(){
console.log("this is test02-fn3");
}
});
//test03.js--模块三
define(function(require,exports,module){var data1="this is test03-data1";
//data2定义为公开
exports.data2="this is test03-data2";
functionfn1(){
console.log("this is test03-fn1");
}
fn1();
functionfn2(){
console.log("this is test03-fn2");
}
exports.fn3 = function(){
console.log("this is test03-fn3");
}
functionfn4(){
console.log("this is test03-fn4");
}
fn4();
});
//test04--模块四
define(function(require,exports,module){var data1="this is test04-data1";
//data2定义为公开
exports.data2="this is test04-data2";
functionfn1(){
console.log("this is test04-fn1");
}
fn1();
functionfn2(){
console.log("this is test04-fn2");
}
exports.fn3 = function(){
console.log("this is test04-fn3");
}
functionfn4(){
console.log("this is test04-fn4");
}
fn4();
});