单利模式
class Singleton {
constructor(name){
this.name=name
}
static getInstance(name){
console.log(name)
if(!this.instance){
console.log(222)
this.instance = new Singleton(name)
}
return this.instance
}
}
单利模式
class Singleton {
constructor(name){
this.name=name
}
static getInstance(name){
console.log(name)
if(!this.instance){
console.log(222)
this.instance = new Singleton(name)
}
return this.instance
}
}