var ModulesManage = (function() {
var modules = {};
function defined(name, deps, impl) {
for (var i = 0; i < deps.length; i++) {
deps[i] = modules[deps[i]];
}
modules[name] = impl.apply(impl, deps);
};
function get(name) {
return modules[name];
};
return {
define: defined,
get: get
};
}());
ModulesManage.define("Person", [], function() {
function ctor(name, age, gender) {
this.name = name;
this.age = age;
this.gender = gender;
}
function eatfood(food) {
console.log(this.name + "eat" + food);
}
ctor.prototype = {
EatFood: eatfood
};
return ctor;
});
var wsp = new(ModulesManage.get("Person"))("Wsp", 20, "Male");
wsp.EatFood("香蕉");
网友评论