-
Notifications
You must be signed in to change notification settings - Fork 2
/
MElegant.js
33 lines (31 loc) · 972 Bytes
/
MElegant.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Created by reco on 2018/8/13.
*/
var MElegant = {
regist:function(className,ClassObject) {
ClassObject = ClassObject || function(){};
var path = className.split(".");
var current = window;
for(var i=0;i<path.length;i++) {
if(i!=(path.length-1)) {
if(typeof current[path[i]]=='undefined') {
current[path[i]] = {};
}
} else {
if(typeof current[path[i]] =='undefined') {
current[path[i]] = ClassObject;
} else {
throw className+"命名空间重复,请修改!";
return false;
}
}
current = current[path[i]];
}
},
extend:function(instance,parent,arg){
instance.extend = parent;
instance.extend.apply(instance,arg);
instance.extend = null;
delete instance.extend;
}
};