初学typescript
namespace Validation { export interface StringValidator { isAcceptable(s: string): boolean; } const numberRegexp = /^[0-9]+$/; export class ZipCodeValidator implements StringValidator { i优艾设计网_PS问答sAcceptable(s: string) { return s.length === 5 && numberRegexp.test(s); } } } //这句什么意思 let validators: { [s: string]: Validation.StringValidator; } = {}; //这里的中括号什么意思? validators["ZIP code"] = new Validation.ZipCodeValidator();
精彩评论