let Single = (function() {
let _instance = null
function init(props) {
return {
publickMethod: function(){
},
value: props.value
}
}
return function(props) {
if(!_instance) {
_instance = init(props)
}
return _instance
}
})()
let instance = Single({value: 10})
console.log(instance)
【JavaScript】设计模式-单例模式
最新推荐文章于 2024-06-26 16:53:17 发布