| 12345678910111213141516171819 |
- /**单例
- *
- * public static getInstance(): XXX{
- return Instance.get(XXX);
- }
- */
- export type IClazz<T> = new (...param: any[]) => T;
- export default class Instance {
- public static get<T>(clazz: IClazz<T>, ...param: any[]): T {
- if (clazz["__Instance__"] == null) {
- clazz["__Instance__"] = new clazz(...param);
- }
- return clazz["__Instance__"];
- }
- }
|