main.js
define(function(require, exports, module) {
window.person={}
var main = {}
main.init = function(){
var m=2;
switch(m){
case 1:
var module1 = require("../test/test1.js");
break;
case 2:
var module2 = require("../test/test2.js"); //没有执行 但是引入了test2.js
break;
}
console.log(window.person)
}
module.exports = main;
});
test1.js
define(function(require, exports, module) {
var object = {};
window.person.name = "wangxiaoming";
module.exports = object;
});
test2.js
define(function(require, exports, module) {
var object = {"name":"lifeixiang"};
window.person.sex="男"
module.exports = object;
});