<style type="text/css">
.box{
width: 200px;
height: 400px;
border: 1px solid black;
background: #CCCCCC;
}
</style>
</head>
<body>
<input type="button" name="btn" id="btn" value="飞秋" />
<script type="text/javascript">
var obj = {
}
function FieQiu(){
if(!FieQiu.instance){
FieQiu.instance = {
ele : document.createElement('div'),
init : function(){
this.ele.className = 'box';
document.body.appendChild(this.ele);
}
}
}
return FieQiu.instance;
}
const oBtn = document.getElementById("btn");
oBtn.onclick = function(){
new FieQiu().init();
}
</script>
</body>
单例模式的编写
最新推荐文章于 2024-11-25 22:59:33 发布