求解let validators: {[s: string]: Vali.StringValidat 财富值50?
初学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();
精彩评论