1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
function
Coding123_net(name, instancename) {
if
(Coding123_net.instances[instancename]) instancename +=
'_1'
;
//如果重名则重新命名实例名称
Coding123_net.instances[instancename] =
this
;
this
.name = name;
this
.showwho =
function
() { alert(
this
.name); }
}
Coding123_net.instances = {};
new
Coding123_net(
"showbo"
,
'i1'
);
new
Coding123_net(
"编程设计网"
,
'i1'
);
//这个重名了,会重新命名为i1_1
new
Coding123_net(
"www.coding123.net"
,
'i3'
);
Coding123_net.instances[
'i1'
].showwho()
Coding123_net.instances[
'i1_1'
].showwho()
Coding123_net.instances[
'i3'
].showwho()
|
JS类中,静态方法获取实例
最新推荐文章于 2025-06-15 14:03:23 发布