优艾设计网

求解let validators: {[s: string]: Vali.StringValidat 财富值50?

优艾设计网 https://www.uibq.com 2023-04-24 16:45 出处:网络 作者:PS教程自学
初学typescript namespace Validation { export interface StringValidator { isAcceptable(s: string): boolean; } const numberRegexp = /^[0-9]+$/; export class ZipCodeValidator implements StringValidator {

初学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();


0

精彩评论

暂无评论...
验证码 换一张
取 消