:rules="[ { required: true, trigger: 'blur', validator: this.checkCanonical }, ]" checkCanonical (rule, value, callback) { if (value) { let isReg = true try { isReg = eval(value) instanceof RegExp } catch (e) { isReg = false } isReg ? callback() : callback(new Error('请输入正确的正则表达式')) } else { callback(new Error('请输入正则表达式')) } },
标签:checkCanonical,正则表达式,是不是,value,callback,isReg,字符串,new From: https://www.cnblogs.com/hwy6/p/17298470.html