初学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();
付费偷看金额在0.1-10元之间
一周热门 更多>