初学typescript
namespace Validation { export interface StringValidator { isAcceptable(s: string): boolean; } const numberRegexp = /^[0-9]+$/; export class ZipCodeValidator implements StringValidator { isAcceptable(s: string) { return s.length === 5 && numberRegexp.test(s); } } }//这句什么意思let validators: { [s: string]: Validation.StringValidator; } = {}; //这里的中括号什么意思?validators["ZIP code"] = new Validation.ZipCodeValidator();
qq_遁去的一_1
相关分类