【发布时间】:2017-10-05 16:05:04
【问题描述】:
我在单页应用程序中有一个应用程序。 我也在外面注册和登录。
我想知道我是否应该用于登录和注册以及密码恢复:
1.带类的标准单例模式。
export class Register {
foo(): any {}
}
2.或者可能只是Register.ts等中的“导出函数foo”?
export function foo: any {}
3.或者一切都保留在模块注册、模块登录中?
module Publics {
export module Register {
export function foo(): any {
// ...
}
}
export module Login {
export function foo(): any {
// ...
}
}
}
增加了1个文件,PublicCommons.ts,具有常用功能...
【问题讨论】:
-
解决方案 #2。并且不要使用关键字
module,它不是模块而是namespace。
标签: oop typescript design-patterns