💡 将 constructor 设置为
protected或者private,致使该类无法在外部实例化, 即可实现。
🌰 示例
1 | class Single { |
❎ 错误用法
1 | const single = new Single() |

✅ 正确用法
1 | Single.echo('hello') |

💡 将 constructor 设置为
protected或者private,致使该类无法在外部实例化, 即可实现。
1 | class Single { |
1 | const single = new Single() |

1 | Single.echo('hello') |
