/***
* 泛型单例模式接口
*/
export default class Singleton {
private static _instance: any = null
//private 私有的
//static 声明静态成员----属于类而不是类的实例
static GetInstance<T>(): T {
if (this._instance === null) {
this._instance = new this()
}
return this._instance
}
}
// class Singleton{
// private static _instance:any=null
// static GetInstance<T>():T{
// if(this._instance===null){
// this._instance=new this()
// }
// return this._instance
// }
// }
单例模式---cocos
最新推荐文章于 2024-07-13 23:29:14 发布